---
title: "Couchbase integration | Grafana Cloud documentation"
description: "Learn about Couchbase Grafana Cloud integration."
---

# Couchbase integration for Grafana Cloud

Couchbase is a distributed NoSQL database which provides high availability, scalability, and performance for large sets of data. This integration for Grafana Cloud allows users to collect metrics and logs from the cluster, node, and bucket levels of a Couchbase clustered deployment.

This integration supports Couchbase 7.0+

This integration includes 4 useful alerts and 3 pre-built dashboards to help monitor and visualize Couchbase metrics and logs.

## Before you begin

Couchbase exposes a [Prometheus metrics endpoint](https://docs.couchbase.com/cloud/app-services/references/rest_api_metrics_static.html) that is enabled by default.

In order to access this endpoint, configure basic authentication with the credentials of a user with an admin role. For more information on roles in Couchbase, see these [docs](https://docs.couchbase.com/server/current/learn/security/roles.html)

## Install Couchbase integration for Grafana Cloud

1. In your Grafana Cloud stack, click **Connections** in the left-hand menu.
2. Find **Couchbase** and click its tile to open the integration.
3. Review the prerequisites in the **Configuration Details** tab and set up Grafana Alloy to send Couchbase metrics and logs to your Grafana Cloud instance.
4. Click **Install** to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your Couchbase setup.

## Configuration snippets for Grafana Alloy

### Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your Couchbase instances, **manually** copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

### Advanced metrics snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
discovery.relabel "metrics_integrations_integrations_couchbase" {
	targets = [{
		__address__ = "<node-hostname>:8091",
	}]

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}

	rule {
		target_label = "couchbase_cluster"
		replacement  = "<your-cluster-name>"
	}
}

prometheus.scrape "metrics_integrations_integrations_couchbase" {
	targets    = discovery.relabel.metrics_integrations_integrations_couchbase.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/couchbase"

	basic_auth {
		username = "<cb-cluster-username>"
		password = "<cb-cluster-password>"
	}
}
```

To monitor your Couchbase instance, you must use a [discovery.relabel](/docs/alloy/latest/reference/components/discovery.relabel/) component to discover your Couchbase Prometheus endpoint and apply appropriate labels, followed by a [prometheus.scrape](/docs/alloy/latest/reference/components/prometheus.scrape) component to scrape it.

Configure the following properties within each `discovery.relabel` component:

- `__address__`: The address to your Couchbase Prometheus metrics endpoint.
- `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Couchbase instance. Make sure this label value is the same for all telemetry data collected for this instance.
- `couchbase_cluster`: The `couchbase_cluster` label to group your Couchbase instances within a cluster. Set the same value for all nodes within your cluster.

If you have multiple Couchbase servers to scrape, configure one `discovery.relabel` for each and scrape them by including each under `targets` within the `prometheus.scrape` component.

### Advanced logs snippets

#### darwin

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_couchbase" {
	path_targets = [{
		__address__       = "localhost",
		__path__          = "/opt/couchbase/var/lib/couchbase/*.log",
		couchbase_cluster = "<your-cluster-name>",
		instance          = constants.hostname,
		job               = "integrations/couchbase",
	}]
}

loki.process "logs_integrations_integrations_couchbase" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.drop {
		expression = "---"
	}

	stage.multiline {
		firstline     = "\\[(ns_server|couchdb):(error|info),.*\\]"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

loki.source.file "logs_integrations_integrations_couchbase" {
	targets    = local.file_match.logs_integrations_integrations_couchbase.targets
	forward_to = [loki.process.logs_integrations_integrations_couchbase.receiver]
}
```

To monitor your Couchbase instance logs, you will use a combination of the following components:

- [local.file\_match](/docs/alloy/latest/reference/components/local.file_match) defines where to find the log file to be scraped. Change the following properties according to your environment:
  
  - `__address__`: The Couchbase instance address
  - `__path__`: The path to the log file.
  - `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Couchbase instance. Make sure this label value is the same for all telemetry data collected for this instance.
  - `couchbase_cluster`: The `couchbase_cluster` label to group your Couchbase instances within a cluster. Set the same value for all nodes within your cluster.
- [loki.process](/docs/alloy/latest/reference/components/loki.process) defines how to process logs before sending it to Loki.
- [loki.source.file](/docs/alloy/latest/reference/components/loki.source.file) sends logs to Loki.

#### linux

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_couchbase" {
	path_targets = [{
		__address__       = "localhost",
		__path__          = "/opt/couchbase/var/lib/couchbase/*.log",
		couchbase_cluster = "<your-cluster-name>",
		instance          = constants.hostname,
		job               = "integrations/couchbase",
	}]
}

loki.process "logs_integrations_integrations_couchbase" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.drop {
		expression = "---"
	}

	stage.multiline {
		firstline     = "\\[(ns_server|couchdb):(error|info),.*\\]"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

loki.source.file "logs_integrations_integrations_couchbase" {
	targets    = local.file_match.logs_integrations_integrations_couchbase.targets
	forward_to = [loki.process.logs_integrations_integrations_couchbase.receiver]
}
```

To monitor your Couchbase instance logs, you will use a combination of the following components:

- [local.file\_match](/docs/alloy/latest/reference/components/local.file_match) defines where to find the log file to be scraped. Change the following properties according to your environment:
  
  - `__address__`: The Couchbase instance address
  - `__path__`: The path to the log file.
  - `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Couchbase instance. Make sure this label value is the same for all telemetry data collected for this instance.
  - `couchbase_cluster`: The `couchbase_cluster` label to group your Couchbase instances within a cluster. Set the same value for all nodes within your cluster.
- [loki.process](/docs/alloy/latest/reference/components/loki.process) defines how to process logs before sending it to Loki.
- [loki.source.file](/docs/alloy/latest/reference/components/loki.source.file) sends logs to Loki.

#### windows

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_couchbase" {
	path_targets = [{
		__address__       = "localhost",
		__path__          = "/opt/couchbase/var/lib/couchbase/*.log",
		couchbase_cluster = "<your-cluster-name>",
		instance          = constants.hostname,
		job               = "integrations/couchbase",
	}]
}

loki.process "logs_integrations_integrations_couchbase" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.drop {
		expression = "---"
	}

	stage.multiline {
		firstline     = "\\[(ns_server|couchdb):(error|info),.*\\]"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

loki.source.file "logs_integrations_integrations_couchbase" {
	targets    = local.file_match.logs_integrations_integrations_couchbase.targets
	forward_to = [loki.process.logs_integrations_integrations_couchbase.receiver]
}
```

To monitor your Couchbase instance logs, you will use a combination of the following components:

- [local.file\_match](/docs/alloy/latest/reference/components/local.file_match) defines where to find the log file to be scraped. Change the following properties according to your environment:
  
  - `__address__`: The Couchbase instance address
  - `__path__`: The path to the log file.
  - `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Couchbase instance. Make sure this label value is the same for all telemetry data collected for this instance.
  - `couchbase_cluster`: The `couchbase_cluster` label to group your Couchbase instances within a cluster. Set the same value for all nodes within your cluster.
- [loki.process](/docs/alloy/latest/reference/components/loki.process) defines how to process logs before sending it to Loki.
- [loki.source.file](/docs/alloy/latest/reference/components/loki.source.file) sends logs to Loki.

## Kubernetes instructions

Instructions for Kubernetes

### Before you begin with Kubernetes

**Please note**: These instructions assume the use of the [Kubernetes Monitoring Helm chart](https://github.com/grafana/k8s-monitoring-helm)

Couchbase exposes a [Prometheus metrics endpoint](https://docs.couchbase.com/cloud/app-services/references/rest_api_metrics_static.html) that is enabled by default.

In order to access this endpoint, configure basic authentication with the credentials of a user with an admin role. For more information on roles in Couchbase, see these [docs](https://docs.couchbase.com/server/current/learn/security/roles.html)

### Configuration snippets for Kubernetes Helm chart

The following snippets provide examples to guide you through the configuration process.

To scrape your Couchbase instances, **manually** modify your Kubernetes Monitoring Helm chart with these configuration snippets.

Replace any values between the angle brackets `<>` in the provided snippets with your desired configuration values.

#### Metrics snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
alloy-metrics:
    extraConfig: |-
        discovery.kubernetes "couchbase" {
            role = "endpoints"
            selectors {
                role = "service"
                field = "metadata.name=<couchbase_service_name>"
            }
        }

        discovery.relabel "couchbase" {
            targets = discovery.kubernetes.couchbase.targets
        
            rule {
                source_labels = ["__meta_kubernetes_namespace", "__meta_kubernetes_pod_name"]
                separator = "-"
                target_label = "instance"
            }
            rule {
                replacement = "<your-couchbase-cluster-name>"
                target_label = "couchbase_cluster"
            }
        }
        
        prometheus.scrape "metrics_couchbase" {        
            targets      = discovery.relabel.couchbase.output
            job_name     = "integrations/couchbase"
            honor_labels = true
            basic_auth {
                username = "<your-couchbase-username>"
                password = "<your-couchbase-password>"
            }
            forward_to   = [prometheus.remote_write.grafana_cloud_metrics.receiver]
        }
```

#### Logs snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
podLogs:
    extraDiscoveryRules: |-
        rule {
            source_labels = ["__meta_kubernetes_pod_name","__meta_kubernetes_pod_container_name"]
            separator     = ":"
            regex         = "<couchbase_pod_name>:<couchbase-log-forwarder>"
            replacement   = "couchbase"
            target_label  = "integration"
        }
        
    extraLogProcessingStages: |-
        stage.match {
            selector = "{integration=\\"couchbase\\"}"
        
            stage.multiline {
                firstline     = \`\\[\d\\] couchbase.log.*\`
                max_lines     = 0
                max_wait_time = "3s"
            }

            stage.drop {
                expression = "---"
            }

            stage.template {
                source   = "instance"
                template = "{{ .namespace }}-{{ .pod }}"
            }

            stage.static_labels {
                values = {
                    couchbase_cluster = "<your-couchbase-cluster-name>",
                    job               = "integrations/couchbase",
                }
            }
        
            stage.labels {
                values = {
                    instance = null,
                    level = null,
                }
            }
        }
```

## Dashboards

The Couchbase integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

- Couchbase bucket overview
- Couchbase cluster overview
- Couchbase node overview

**Couchbase cluster overview (top nodes)**

**Couchbase node overview (memory)**

**Couchbase bucket overview (storage)**

## Alerts

The Couchbase integration includes the following useful alerts:

Expand table

| Alert                         | Description                                                                                                 |
|-------------------------------|-------------------------------------------------------------------------------------------------------------|
| CouchbaseHighCPUUsage         | Critical: The node CPU usage has exceeded the critical threshold.                                           |
| CouchbaseHighMemoryUsage      | Critical: There is a limited amount of memory available for a node.                                         |
| CouchbaseMemoryEvictionRate   | Warning: There is a spike in evictions in a bucket, which indicates high memory pressure.                   |
| CouchbaseInvalidRequestVolume | Warning: There is a high volume of incoming invalid requests, which may indicate a DOS or injection attack. |

## Metrics

The most important metrics provided by the Couchbase integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

- backup\_data\_size
- cbas\_direct\_memory\_used\_bytes
- cm\_http\_requests\_total
- couch\_docs\_actual\_disk\_size
- index\_avg\_scan\_latency
- index\_cache\_hits
- index\_cache\_misses
- index\_memory\_used\_total
- index\_num\_requests
- kv\_curr\_connections
- kv\_curr\_items
- kv\_ep\_num\_value\_ejects
- kv\_mem\_used\_bytes
- kv\_num\_high\_pri\_requests
- kv\_num\_vbuckets
- kv\_ops
- kv\_ops\_failed
- kv\_vb\_queue\_memory\_bytes
- n1ql\_errors
- n1ql\_invalid\_requests
- n1ql\_requests
- n1ql\_requests\_1000ms
- n1ql\_requests\_250ms
- n1ql\_requests\_5000ms
- n1ql\_requests\_500ms
- sys\_cpu\_utilization\_rate
- sys\_mem\_actual\_free
- sys\_mem\_actual\_used
- up
- xdcr\_data\_replicated\_bytes
- xdcr\_docs\_received\_from\_dcp\_total

## Changelog

md ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```md
# 1.0.0 - March 2024

- Added cluster selector to dashboards for kubernetes support
- Added default cluster label to agent config
- Bump version to 1.0.0

# 0.0.3 - September 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.2 - August 2023

* Add regex filter for logs datasource

# 0.0.1 - July 2023

- Initial release
```

## Cost

By connecting your Couchbase instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see [Active series and dpm usage](/docs/grafana-cloud/fundamentals/active-series-and-dpm/) and [Cloud tier pricing](/products/cloud/pricing/).
