Configure Prometheus Metrics Collection

    +
    You can set up the Autonomous Operator to use the Couchbase Prometheus Exporter for metrics collection.

    Overview

    Prometheus is the de facto metrics collection platform for use in Kubernetes environments. The Autonomous Operator provides native integration with the Couchbase Prometheus Exporter for collecting and exposing Couchbase Server metrics.

    Prometheus metrics collection is enabled in the CouchbaseCluster resource. The configuration allows you to specify a Couchbase-provided container image that contains the Prometheus Exporter. The Autonomous Operator injects the image as a "sidecar" container in each Couchbase Server pod.

    Configuration

    Prometheus metrics collection is enabled in the CouchbaseCluster resource.

    apiVersion: couchbase/v2
    kind: CouchbaseCluster
    spec:
      monitoring:
        prometheus:
          enabled: true (1)
          image: couchbase/exporter:1.0.2 (2)
          authorizationSecret: cb-metrics-token (3)
    1 Setting spec.monitoring.prometheus.enabled to true enables injection of the sidecar into Couchbase Server pods.
    2 If the spec.monitoring.prometheus.image field is left unspecified, then the dynamic admission controller will automatically populate it with the most recent container image that was available when the installed version of the Autonomous Operator was released. The default image for open source Kubernetes comes from Docker Hub, and the default image for OpenShift comes from Red Hat Container Catalog.

    If pulling directly from the the Red Hat Container Catalog, then the path will be something similar to registry.connect.redhat.com/couchbase/exporter:1.0.2-2 (you can refer to the catalog for the most recent images). If ImagePullSecrets are required to access the image, they are inherited from the Couchbase Server pod and can be set explicitly with the spec.servers[].pod.spec.imagePullSecrets field or implicitly with a service account specified with the spec.servers[].pod.spec.serviceAccountName field.

    3 You can optionally specify a Kubernetes Secret that contains a bearer token value that clients will need to use to gain access to the Prometheus metrics.

    If you wish to create a Kubernetes secret with a bearer token, simply edit and create the following definition:

    apiVersion: v1
    kind: Secret
    metadata:
      name: cb-metrics-token
    type: Opaque
    stringData:
      token: your-plain-text-bearer-token-here

    The stringData field allows you to put a non-base64 encoded string directly into the Secret, and Kubernetes will then encode the string for you when the Secret is created or updated.

    Important Considerations
    • You can enable/disable Prometheus metric collection at any time during the cluster’s lifecycle. However, since Pod resources are immutable, enabling or disabling metric collection will require a rolling upgrade of the cluster.

    • Only official Prometheus images provided by Couchbase are supported.

      In addition, you should ensure that your image source is trusted. The sidecar container requires access to the Couchbase cluster administrative credentials in order to login and perform collection. Granting these credentials to arbitrary code is potentially harmful.

    Using Exported Metrics

    Once configured, active metrics can be collected from each Couchbase Server pod on port 9091.

    The Autonomous Operator does not create or manage resources for third-party software. Prometheus scrape targets must be manually created by the user. However, you might find the following resources helpful when setting up your Prometheus environment: