Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-10765

Create a documentation page for Capella on Setting up Prometheus

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Duplicate
    • Major
    • None
    • None
    • None
    • Security Level: Public
    • 0

    Description

      Couchbase Server documentation has a page called Set up Prometheus to Consume Couchbase Metrics (link: https://docs.couchbase.com/server/current/manage/monitor/set-up-prometheus-for-monitoring.html ).

      The ask is to create a similar type of page for the Capella cluster.

      Under the ticket: https://couchbasecloud.zendesk.com/agent/tickets/16816, i have put together a draft of the answer to the customer that we can take advantage of to create a Capella documentation page (see below)



       
       

      Note:

      The message below is based on the Set up Prometheus to Consume Couchbase Metrics doc (link) with slight adaptation for the Capella clusters
       

      With Couchbase 7.x, it’s not necessary to write a custom Prometheus Exporter. This page will demonstrate how to enable a Prometheus server to read from Couchbase’s Prometheus-ready endpoints.

      Prerequisites:

      • Make sure that you have Docker installed and running on your machine.
      • In the Capella UI create a db user with read/write permissions to all the buckets. It can be created under Connect tab -> Database Credentials
      • add your IP to the AllowedIP list  located under Connect tab -> Manage Allowed IP
      • on your local machine create a directory named prometheus/ and cd into it

       

      General steps:

      • Place the below script in the prometheus/ directory and run it to download the couchbase_sd_config_.yaml (aka target file) and update the ports
      • Place the Cluster root certificate into the prometheus/ directory.  The certificate can be found under Connect tab -> Security Certificate
      • Place the below configuration file in the prometheus/ directory and update the required fields

       
      After doing so, the prometheus/ directory on your local machine will contain:
      1) script
      2) Cluster root certificate
      3) couchbase_sd_config_.yaml (aka target file)
      4) prometheus.yml
       

      Supplemental Script:

      The purpose of the script is to dynamically update the  couchbase_sd_config_.yaml (aka target file), which will contain all nodes of the cluster. The hostnames of the nodes and their number could change due to vertical or horizontal scaling.
      Depending on your use case, you might want to add this script as a cron job
       

       

      #!/bin/bash
       
      1. retrieve 1 hostname of the cluster.
      URL=$(nslookup -type=SRV _couchbases._tcp.cb.rqcaoawb-yuwzovl.cloud.couchbase.com |
      | awk '{print $NF}' | awk 'NR==5 {print $0}' | sed 's/.$//')
       
      1. retrieve the target file with all hostnames of the cluster 
      wget -O couchbase_sd_config_.yaml --content-disposition https://$URL:18091/prometheus_sd_config.yaml |
      --http-user dbuser --http-password Password12! --no-check-certificate
       
      1. replace default port 8091 with secure port 18091 in the target file
      while true
      do 
      sed -i '' 's/8091/18091/g' couchbase_sd_config_.yaml && break
      sleep 3
      done

       

      where:
      cb.rqcaoawb-yuwzovl.cloud.couchbase.com}} -> the public endpoint of your cluster located under the Connection tab
      dbuser -> database user
      Password12!-> password of the database user
       

      Create the Prometheus configuration file

      Create a new file called prometheus.yml in the prometheus/ directory. The basic configuration may look something like this:

       

       

      scrape_configs:
      • job_name: 'couchbase_cluster'
      scheme: https
      scrape_interval: 15s
      basic_auth:
      username: 'dbuser'
      password: 'Password12!'
      tls_config:
      ca_file: root-certificate.pem
      file_sd_configs:
      • files:
      • 'couchbase_sd_config_.yaml'
      refresh_interval: 15s

       

      where
      dbuser-> database user
      Password12!-> password of the database user
      root-certificate.pem -> Cluster root certificate
      couchbase_sd_config_.yaml-> target file with all the nodes
       

      Install Prometheus

      Open a terminal window and run the following command to provision Prometheus:

       

      docker run -p 9090:9090 -v ~/prometheus:/etc/prometheus -d --name prometheus prom/prometheus

       

      where,
      -p 9090:9090 is host-port and container-port
      -v /prometheus:/etc/prometheus  is the mapping of the Prometheus configuration directory to the host machine configuration. /prometheus will be mapped on to the Prometheus instance configuration directory inside the Docker container.
        

      Testing

      Once the Docker container has started up, visit http://localhost:9090/targets to ensure that Prometheus is accessing the cluster correctly and nodes of the cluster are visible.
      Optionally, import the "Travel Sample" bucket from under Tools -> Import page. Then visit http://localhost:9090/graph and query kv_curr_items

      Attachments

        Issue Links

          Activity

            People

              tech-comm-team@couchbase.com Tech Comm Team
              Francis.roberts Francis Roberts
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty