> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitor CockroachDB with Kibana

[Kibana](https://www.elastic.co/kibana) is a platform that visualizes data on the [Elastic Stack](https://www.elastic.co/elastic-stack). This page shows how to use the [CockroachDB module for Metricbeat](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-cockroachdb) to collect metrics exposed by your CockroachDB self-hosted cluster's [Prometheus endpoint](https://docs.cockroachlabs.com/docs/v24.1/monitoring-and-alerting.md#prometheus-endpoint) in Elasticsearch and how to visualize those metrics with Kibana.

> [!TIP]
>
> To export metrics from a CockroachDB Cloud cluster, refer to [Export Metrics From a CockroachDB Dedicated Cluster](https://docs.cockroachlabs.com/docs/cockroachcloud/export-metrics.md) instead of this page.

In this tutorial, you will enable the CockroachDB module for Metricbeat and visualize the data in Kibana.

> [!TIP]
>
> For more information about using the CockroachDB module for Metricbeat, see the [Elastic documentation](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-cockroachdb).
>
> If you run into problems with this integration, please file an issue on the [Beats issue tracker](https://github.com/elastic/beats).

## Before you begin

Either of the following:

* Hosted [Elasticsearch Service](https://www.elastic.co/guide/en/kibana/current/get-started#set-up-on-cloud) with [Metricbeat configured](https://www.elastic.co/guide/en/beats/metricbeat/current/configure-cloud-id)
* Self-managed [Elastic Stack](https://www.elastic.co/guide/en/elastic-stack-get-started/current/get-started-elastic-stack) with [Metricbeat installed](https://www.elastic.co/guide/en/beats/metricbeat/7.13/metricbeat-installation-configuration)

> [!NOTE]
>
> This tutorial assumes that you have [started a secure CockroachDB cluster](https://docs.cockroachlabs.com/docs/v24.1/secure-a-cluster.md). [CockroachDB Cloud](https://docs.cockroachlabs.com/docs/cockroachcloud/index.md) does not expose a compatible monitoring endpoint.

## Step 1. Enable CockroachDB module

From your Metricbeat installation directory, run:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
./metricbeat modules enable cockroachdb
```

### Configure security certificates

Open `modules.d/cockroachdb.yml` in your Metricbeat installation directory.

Follow the steps in the [Elastic documentation](https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-ssl) to enable SSL on the CockroachDB module.

For example, if you used [`cockroach cert`](https://docs.cockroachlabs.com/docs/v24.1/cockroach-cert) to [secure your cluster](https://docs.cockroachlabs.com/docs/v24.1/secure-a-cluster.md#step-1-generate-certificates), the YAML should look like:

```yaml theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
- module: cockroachdb
  metricsets: ['status']
  period: 10s
  hosts: ['localhost:8080']
  enabled: true
  ssl.verification_mode: full
  ssl.certificate_authorities: "/custom/dir/path/ca.crt"
  ssl.certificate: "/custom/dir/path/client.root.crt"
  ssl.key: "/custom/dir/path/client.root.key"
```

`ssl.certificate_authorities`, `ssl.certificate`, and `ssl.key` should specify the full file paths to your CA certificate, client certificate, and client key, respectively.

## Step 2. Start Metricbeat

Load the Kibana dashboards (this may take a few moments):

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
./metricbeat setup
```

Launch Metricbeat:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
./metricbeat -e
```

## Step 3. View CockroachDB dashboards on Kibana

Open the Kibana web interface and click **Dashboard**.

Search for the CockroachDB dashboard:

![CockroachDB dashboard selection for Metricbeat](https://mintcdn.com/cockroachlabs/bBD0UEapbn6fk8Rb/images/common/kibana-crdb-dashboard-selection.png?fit=max\&auto=format\&n=bBD0UEapbn6fk8Rb\&q=85\&s=c4bb1d41889712785164e428bf6f37a1)

Click the dashboard title to open the dashboard, which presents metrics on replicas and query performance:

![CockroachDB Overview dashboard for Metricbeat](https://mintcdn.com/cockroachlabs/iiBVxthghoAOO3UM/images/common/kibana-crdb-dashboard.png?fit=max\&auto=format\&n=iiBVxthghoAOO3UM\&q=85\&s=0b0843ae4ebd5af4209ec89527197062)

## Step 4. Run a sample workload

To test the dashboard functionality, use [`cockroach workload`](https://docs.cockroachlabs.com/docs/v24.1/cockroach-workload) to run a sample workload on the cluster.

Initialize the workload for MovR, a fictional vehicle-sharing company:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
cockroach workload init movr 'postgresql://root@localhost:26257?sslcert=certs%2Fclient.root.crt&sslkey=certs%2Fclient.root.key&sslmode=verify-full&sslrootcert=certs%2Fca.crt'
```

Run the MovR workload for 5 minutes:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
cockroach workload run movr --duration=5m 'postgresql://root@localhost:26257?sslcert=certs%2Fclient.root.crt&sslkey=certs%2Fclient.root.key&sslmode=verify-full&sslrootcert=certs%2Fca.crt'
```

Click **Refresh**. The query metrics will appear on the dashboard:

![CockroachDB Overview dashboard for Metricbeat with SQL metrics](https://mintcdn.com/cockroachlabs/iiBVxthghoAOO3UM/images/common/kibana-crdb-dashboard-sql.png?fit=max\&auto=format\&n=iiBVxthghoAOO3UM\&q=85\&s=bfe3086f0cfc23ea6b7e3b7cddc5b744)

## See also

* [Monitoring and Alerting](https://docs.cockroachlabs.com/docs/v24.1/monitoring-and-alerting.md)
* [DB Console Overview](https://docs.cockroachlabs.com/docs/v24.1/ui-overview.md)
* [Logging Overview](https://docs.cockroachlabs.com/docs/v24.1/logging-overview.md)
