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

# Monitor CockroachDB with Kibana

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

[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.html) to collect metrics exposed by your CockroachDB CockroachDB cluster's <InternalLink path="monitoring-and-alerting#prometheus-endpoint">Prometheus endpoint</InternalLink> in Elasticsearch and how to visualize those metrics with Kibana.

To export metrics from a CockroachDB CockroachDB Cloud cluster, refer to <InternalLink version="cockroachcloud" path="export-metrics">Export Metrics From a CockroachDB CockroachDB Dedicated Cluster</InternalLink> 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.html).

  If you run into problems with this integration, please file an issue on the [Beats issue tracker](https://github.com/elastic/beats).
</Tip>

## Before you begin

Either of the following:

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

<Note>
  This tutorial assumes that you have <InternalLink path="secure-a-cluster">started a secure CockroachDB cluster</InternalLink>. <InternalLink version="cockroachcloud" path="index">CockroachDB CockroachDB Cloud</InternalLink> does not expose a compatible monitoring endpoint.
</Note>

## 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.html) to enable SSL on the CockroachDB module.

For example, if you used <InternalLink path="cockroach-cert">`cockroach cert`</InternalLink> to <InternalLink path="secure-a-cluster#step-1-generate-certificates">secure your cluster</InternalLink>, 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:

<img src="https://mintcdn.com/cockroachlabs/LmGUwqXk_Q0o006z/images/v24.2/kibana-crdb-dashboard-selection.png?fit=max&auto=format&n=LmGUwqXk_Q0o006z&q=85&s=decb3ae83126de2e8b3aab84c364708c" alt="CockroachDB dashboard selection for Metricbeat" width="2988" height="909" data-path="images/v24.2/kibana-crdb-dashboard-selection.png" />

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

<img src="https://mintcdn.com/cockroachlabs/LmGUwqXk_Q0o006z/images/v24.2/kibana-crdb-dashboard.png?fit=max&auto=format&n=LmGUwqXk_Q0o006z&q=85&s=96ccbf569606afe0b7cff4f812c02764" alt="CockroachDB Overview dashboard for Metricbeat" width="3333" height="1877" data-path="images/v24.2/kibana-crdb-dashboard.png" />

## Step 4. Run a sample workload

To test the dashboard functionality, use <InternalLink path="cockroach-workload">`cockroach workload`</InternalLink> 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:

<img src="https://mintcdn.com/cockroachlabs/LmGUwqXk_Q0o006z/images/v24.2/kibana-crdb-dashboard-sql.png?fit=max&auto=format&n=LmGUwqXk_Q0o006z&q=85&s=4c5054ab1a102b3d62b735192a97836d" alt="CockroachDB Overview dashboard for Metricbeat with SQL metrics" width="3340" height="1878" data-path="images/v24.2/kibana-crdb-dashboard-sql.png" />

## Step 5. Disable DB Console's local storage of metrics (optional)

If you rely on external tools such as Kibana for storing and visualizing your cluster's time-series metrics, Cockroach Labs recommends that you <InternalLink path="operational-faqs#disable-time-series-storage">disable the DB Console's storage of time-series metrics</InternalLink>.

When storage of time-series metrics is disabled, the cluster continues to expose its metrics via the <InternalLink path="monitoring-and-alerting#prometheus-endpoint">Prometheus endpoint</InternalLink>. The DB Console stops storing new time-series cluster metrics and eventually deletes historical data. The Metrics dashboards in the DB Console are still available, but their visualizations are blank. This is because the dashboards rely on data that is no longer available. You can create queries, visualizations, and alerts in Kibana based on the data it is collecting from your cluster's Prometheus endpoint.

## See also

* <InternalLink path="monitoring-and-alerting">Monitoring and Alerting</InternalLink>
* <InternalLink path="ui-overview">DB Console Overview</InternalLink>
* <InternalLink path="logging-overview">Logging Overview</InternalLink>
