Skip to main content

CockroachDB

Collect metrics from CockroachDB — SQL throughput, replication health, storage usage, and node liveness — using CockroachDB's built-in Prometheus endpoint. No additional exporter is required.

Pattern: CockroachDB /_status/vars → Prometheus scrape → xScaler remote_write


Prerequisites

  • CockroachDB 21.1 or later
  • Network access to the CockroachDB HTTP port (default: 8080)
  • xScaler tenant credentials (token + tenant ID)

Option A — Prometheus Exporter

CockroachDB exposes a native Prometheus endpoint at /_status/vars on its HTTP port. No exporter installation is needed — point Prometheus directly at each node:

scrape_configs:
- job_name: cockroachdb
metrics_path: /_status/vars
scheme: http
static_configs:
- targets:
- "cockroach-node-1:8080"
- "cockroach-node-2:8080"
- "cockroach-node-3:8080"
scrape_interval: 30s

remote_write:
- url: https://euw1-01.m.xscalerlabs.com/api/v1/push
authorization:
type: Bearer
credentials: <token>
headers:
X-Scope-OrgID: "<tenant-id>"

Option B — Grafana Alloy

prometheus.scrape "cockroachdb" {
targets = [
{"__address__" = "cockroach-node-1:8080", "__metrics_path__" = "/_status/vars"},
{"__address__" = "cockroach-node-2:8080", "__metrics_path__" = "/_status/vars"},
{"__address__" = "cockroach-node-3:8080", "__metrics_path__" = "/_status/vars"},
]
scrape_interval = "30s"
forward_to = [prometheus.remote_write.xscaler.receiver]
}

prometheus.remote_write "xscaler" {
endpoint {
url = "https://euw1-01.m.xscalerlabs.com/api/v1/push"
authorization {
type = "Bearer"
credentials = "<token>"
}
headers = { "X-Scope-OrgID" = "<tenant-id>" }
}
}

Option C — OpenTelemetry Collector

receivers:
prometheus:
config:
scrape_configs:
- job_name: cockroachdb
metrics_path: /_status/vars
static_configs:
- targets:
- "cockroach-node-1:8080"
- "cockroach-node-2:8080"
- "cockroach-node-3:8080"
scrape_interval: 30s

processors:
batch: {}

exporters:
otlphttp/xscaler:
endpoint: https://euw1-01.m.xscalerlabs.com
headers:
Authorization: "Bearer <token>"
X-Scope-OrgID: "<tenant-id>"
compression: gzip

service:
pipelines:
metrics:
receivers: [prometheus]
processors: [batch]
exporters: [otlphttp/xscaler]

Logs

Collect CockroachDB structured log output. Add the following to your Alloy config:

local.file_match "cockroachdb_logs" {
path_targets = [{
__address__ = "localhost",
__path__ = "/var/log/cockroach*.log",
instance = constants.hostname,
job = "integrations/cockroachdb",
}]
}

loki.source.file "cockroachdb_logs" {
targets = local.file_match.cockroachdb_logs.targets
forward_to = [loki.write.xscaler.receiver]
}

loki.write "xscaler" {
endpoint {
url = "https://euw1-01.l.xscalerlabs.com/api/v1/logs/push"

http_client_config {
authorization {
type = "Bearer"
credentials = env("XSCALER_TOKEN")
}
}

headers = { "X-Scope-OrgID" = env("XSCALER_TENANT_ID") }
}
}

Key metrics

MetricDescription
sql_connsCurrent number of active SQL client connections
sql_txn_commit_countTotal number of committed SQL transactions
sql_txn_rollback_countTotal number of rolled-back SQL transactions
rebalances_leaseTransfersNumber of lease transfers initiated for rebalancing
capacity_usedStorage capacity currently used across all nodes in bytes
ranges_underreplicatedNumber of ranges with fewer replicas than the replication factor
liveness_livenodesNumber of nodes currently considered live by the cluster