---
title: CockroachDB integration
source: https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/integrations-list/cockroach-db-integration
---

[Cockroach Database](https://www.cockroachlabs.com/docs/) is a distributed SQL database built on a transactional and strongly-consistent key-value store.

Cockroach Database has these characteristics:

-   Scales horizontally
-   Survives disk, machine, rack, and even data center failures with minimal latency disruption and no manual intervention
-   Supports strongly-consistent ACID transactions
-   Provides a familiar SQL API for structuring, manipulating, and querying data

CockroachDB generates detailed time series metrics for each node in a cluster. [Monitor CockroachDB with Prometheus](https://www.cockroachlabs.com/docs/v22.1/monitor-cockroachdb-with-prometheus.html#before-you-begin) shows you how to pull these metrics into Prometheus.

Use New Relic to monitor:

-   Cluster health
-   Node health
-   Store and disk capacity
-   SQL queries performance
-   High open file descriptor count
-   Certificate expirations

![CockroachDB Dashboard Screenshot](https://docs.newrelic.com/images/infrastructure_screenshot-crop-cockroachdb-dashboard.webp "CockroachDB Dashboard")

## Enable the integration

Follow these steps to enable the integration.

1.  Follow the  [CockroachDB documentation](https://www.cockroachlabs.com/docs/v22.1/monitor-cockroachdb-with-prometheus.html) for Prometheus to discover the CockroachDB metrics endpoints.

2.  Set up Prometheus monitoring. Prometheus metrics needs to be integrated with New Relic, you can use the Prometheus Agent or the Remote Write integration, see [how to send Prometheus metrics](https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/install-configure-prometheus-agent/get-started/send-prometheus-metric-data-new-relic/).

    > #### ⚠️ IMPORTANT
    >
    > The [Prometheus Agent](https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/install-configure-prometheus-agent/setup-prometheus-agent#scrape-metrics-only-from-prometheus-integrations-scrape-prometheus-integrations) only scrapes metrics by default from a [set of integrations](https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/integrations-list/integrations-list-intro).
    >
    > In this case, you must identify your pod or endpoint with one of the these labels `app.kubernetes.io/name`, `app.newrelic.io/name`, `k8s-app` containing the string `cockroachdb`.

3.  Use the following query to confirm metrics are being ingested as expected:

    ```sql
    SELECT * FROM Metric WHERE metricName = 'rocksdb_num_sstables'
    ```

4.  Install the [CockroachDB quickstart](https://newrelic.com/instant-observability/?search=cockroachdb) to access built-in dashboards and [alerts](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/learn-alerts/introduction-alerts/).

    > #### ⚠️ IMPORTANT
    >
    > Some charts of the dashboard include queries with conditions that require the identification of your pod or endpoint with one of the these labels `app.kubernetes.io/name`, `app.newrelic.io/name`, `k8s-app` containing the string `cockroachdb`.

    Once you imported, you can edit or clone the assets to adapt them to your specific requirements.

    ### Remote Write integration

    By default, the Prometheus agent default's configuration includes the corresponding rules. When you use the Remote Write integration, it's not possible to infer the type properly because of the CockroachDB metrics naming.
    In this case, you have to include these rules to [override the metric type](https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/install-configure-remote-write/set-your-prometheus-remote-write-integration/#override-mapping):

    ```yaml
    - source_labels: [__name__]
      separator: ;
      regex: timeseries_write_(.*)
      target_label: newrelic_metric_type
      replacement: counter
      action: replace
    - source_labels: [__name__]
      separator: ;
      regex: sql_byte(.*)
      target_label: newrelic_metric_type
      replacement: counter
      action: replace
    ```

## Find and use the data

### Metrics

Prometheus metrics are stored as dimensional metrics. You can [query using NRQL](https://docs.newrelic.com/docs/telemetry-data-platform/get-data/apis/query-metric-data-type/) or use the [Data Explorer](https://docs.newrelic.com/docs/query-your-data/explore-query-data/browse-data/introduction-data-explorer/) to browse the available metrics, facet, and filter by the associated dimensions.

The different sets of metrics exposed by this integration are defined in the [CockroachDB documentation](https://www.cockroachlabs.com/docs/stable/monitoring-and-alerting.html).

Use the following NRQL queries to understand the CockroachDB metrics being ingested in New Relic.

**Prometheus agent of New Relic**

-   List unique metric names:

    ```sql
    FROM Metric SELECT uniques(metricName) 
    WHERE (app_kubernetes_io_name LIKE '%cockroach%' OR app_newrelic_com_name LIKE '%cockroach%' OR k8s_app LIKE '%cockroach%') 
    LIMIT MAX
    ```

-   Count number of metric updates:

    ```sql
    FROM Metric SELECT datapointcount() 
    WHERE (app_kubernetes_io_name LIKE '%cockroach%' OR app_newrelic_com_name LIKE '%cockroach%' OR k8s_app LIKE '%cockroach%') 
    FACET metricName
    ```

-   Estimate data ingestion (daily ingest, in bytes):

    ```sql
    FROM Metric SELECT bytecountestimate() 
    WHERE (app_kubernetes_io_name LIKE '%cockroach%' OR app_newrelic_com_name LIKE '%cockroach%' OR k8s_app LIKE '%cockroach%') 
    SINCE 1 day ago
    ```

**Other**

> #### 💡 TIP
>
> Adjust the job name as per your configuration settings.

-   List unique metric names:

    ```sql
    FROM Metric SELECT uniques(metricName) WHERE job = 'cockroachdb' LIMIT MAX
    ```

-   Count number of metric updates:

    ```sql
    FROM Metric SELECT datapointcount() WHERE job='cockroachdb' FACET metricName
    ```

-   Estimate data ingestion (daily ingest, in bytes):

    ```sql
    FROM Metric SELECT bytecountestimate() WHERE job='cockroachdb' SINCE 1 day ago
    ```

## Troubleshooting

Follow the troubleshooting tips from [CockroachDB documentation](https://www.cockroachlabs.com/docs/v22.1/monitor-cockroachdb-with-prometheus.html) to make sure that metrics are configured as expected on your cluster.

You can also check the specific [troubleshooting guidelines](https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/troubleshooting/no-data-appears-prometheus-integration) for Prometheus integrations.
