Skip to main content
CockroachDB generates detailed time series metrics for each node in a cluster. This page shows you how to pull these metrics into Prometheus, a tool for storing, aggregating, and querying time series data. It also shows you how to connect Grafana and Alertmanager to Prometheus for flexible data visualizations and notifications.
This tutorial explores the CockroachDB self-hosted integration with Prometheus. For the CockroachDB Advanced integration with Prometheus, refer to instead of this page.

Before you begin

  • Make sure you have already started a CockroachDB cluster, either or in a .

Step 1. Install Prometheus

  1. Download the 2.x Prometheus tarball for your OS.
  2. Extract the binary and add it to your system PATH. This makes it easy to start Prometheus from any shell.
  3. Make sure Prometheus installed successfully:

Step 2. Configure Prometheus

  1. Download the starter for CockroachDB:
    When you examine the configuration file, you’ll see that it is set up to scrape the time series metrics of a single, insecure local node every 10 seconds:
    • scrape_interval: 10s defines the scrape interval.
    • metrics_path: '/_status/vars' defines the Prometheus-specific CockroachDB endpoint for scraping time series metrics.
    • scheme: 'http' specifies that the cluster being scraped is insecure.
    • targets: ['localhost:8080'] specifies the hostname and http-port of the Cockroach node to collect time series metrics on.
  2. Edit the configuration file to match your deployment scenario:
ScenarioConfig Change
Multi-node local clusterExpand the targets field to include 'localhost:' for each additional node.
Production clusterChange the targets field to include ':' for each node in the cluster. Also, be sure your network configuration allows TCP communication on the specified ports.
Secure clusterUncomment scheme: 'https' and comment out scheme: 'http'.
  1. Create a rules directory and download the and for CockroachDB into it:

Step 3. Start Prometheus

  1. Start the Prometheus server, with the --config.file flag pointing to the configuration file:
  2. Point your browser to http://<hostname of machine running prometheus:9090, where you can use the Prometheus UI to query, aggregate, and graph CockroachDB time series metrics.
    • Prometheus auto-completes CockroachDB time series metrics for you, but if you want to see a full listing, with descriptions, point your browser to http://<hostname of a CockroachDB node:8080/_status/vars.
    • For more details on using the Prometheus UI, see their official documentation.

Step 4. Send notifications with Alertmanager

Active monitoring helps you spot problems early, but it is also essential to send notifications when there are events that require investigation or intervention. In step 2, you already downloaded CockroachDB’s starter . Now, download, configure, and start Alertmanager.
  1. Download the latest Alertmanager tarball for your OS.
  2. Extract the binary and add it to your system PATH. This makes it easy to start Alertmanager from any shell.
  3. Make sure Alertmanager installed successfully:
  4. Edit the Alertmanager configuration file that came with the binary, alertmanager.yml, to specify the desired receivers for notifications. For example, your configuration may resemble:
  5. Start the Alertmanager server, with the --config.file flag pointing to the configuration file:
  6. Point your browser to http://<hostname of machine running alertmanager:9093, where you can use the Alertmanager UI to define rules for silencing alerts.
  7. Now that Alertmanager is configured and running, you can optionally if you prefer.

Step 5. Visualize metrics in Grafana

Although Prometheus lets you graph metrics, Grafana is a much more powerful visualization tool that integrates with Prometheus easily.
  1. Install and start Grafana for your OS.
  2. Point your browser to http://<hostname of machine running grafana:3000 and log into the Grafana UI with the default username/password, admin/admin, or create your own account.
  3. Add Prometheus as a datasource, and configure the datasource as follows:
FieldDefinition
NamePrometheus
DefaultTrue
TypePrometheus
Urlhttp://:9090
AccessDirect
  1. Download the starter Grafana dashboards for CockroachDB:
  2. Add the dashboards to Grafana.

See also