Skip to main content

CockroachDB

Plugin: go.d.plugin Module: cockroachdb

Overview

This collector monitors CockroachDB servers.

It scrapes Prometheus metrics from the CockroachDB /_status/vars endpoint.

It also provides top-queries and running-queries functions using SQL statement statistics (crdb_internal.cluster_statement_statistics) and the SHOW CLUSTER STATEMENTS command.

This collector is supported on all platforms.

This collector supports collecting metrics from multiple instances of this integration, including remote instances.

The top-queries and running-queries functions require:

  • A SQL user with VIEWACTIVITY or VIEWACTIVITYREDACTED privileges.
  • Access to crdb_internal.cluster_statement_statistics (may require SET allow_unsafe_internals = on on newer versions).

Default Behavior

Auto-Detection

This integration doesn't support auto-detection.

Limits

The default configuration for this integration does not impose any limits on data collection.

Performance Impact

The default configuration for this integration is not expected to impose a significant performance impact on the system.

Metrics

Metrics grouped by scope.

The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.

Per CockroachDB instance

These metrics refer to the entire monitored application.

This scope has no labels.

Metrics:

MetricDimensionsUnit
cockroachdb.process_cpu_time_combined_percentageusedpercentage
cockroachdb.process_cpu_time_percentageuser, syspercentage
cockroachdb.process_cpu_timeuser, sysms
cockroachdb.process_memoryrssKiB
cockroachdb.process_file_descriptorsopenfd
cockroachdb.process_uptimeuptimeseconds
cockroachdb.host_disk_bandwidthread, writeKiB
cockroachdb.host_disk_operationsreads, writesoperations
cockroachdb.host_disk_iops_in_progressin_progressiops
cockroachdb.host_network_bandwidthreceived, sentkilobits
cockroachdb.host_network_packetsreceived, sentpackets
cockroachdb.live_nodeslive_nodesnodes
cockroachdb.node_liveness_heartbeatssuccessful, failedheartbeats
cockroachdb.total_storage_capacitytotalKiB
cockroachdb.storage_capacity_usabilityusable, unusableKiB
cockroachdb.storage_usable_capacityavailable, usedKiB
cockroachdb.storage_used_capacity_percentagetotal, usablepercentage
cockroachdb.sql_connectionsactiveconnections
cockroachdb.sql_bandwidthreceived, sentKiB
cockroachdb.sql_statements_totalstarted, executedstatements
cockroachdb.sql_errorsstatement, transactionerrors
cockroachdb.sql_started_ddl_statementsddlstatements
cockroachdb.sql_executed_ddl_statementsddlstatements
cockroachdb.sql_started_dml_statementsselect, update, delete, insertstatements
cockroachdb.sql_executed_dml_statementsselect, update, delete, insertstatements
cockroachdb.sql_started_tcl_statementsbegin, commit, rollback, savepoint, savepoint_cockroach_restart, release_savepoint_cockroach_restart, rollback_to_savepoint_cockroach_restartstatements
cockroachdb.sql_executed_tcl_statementsbegin, commit, rollback, savepoint, savepoint_cockroach_restart, release_savepoint_cockroach_restart, rollback_to_savepoint_cockroach_restartstatements
cockroachdb.sql_active_distributed_queriesactivequeries
cockroachdb.sql_distributed_flowsactive, queuedflows
cockroachdb.live_bytesapplications, systemKiB
cockroachdb.logical_datakeys, valuesKiB
cockroachdb.logical_data_countkeys, valuesnum
cockroachdb.kv_transactionscommitted, fast-path_committed, abortedtransactions
cockroachdb.kv_transaction_restartswrite_too_old, write_too_old_multiple, forwarded_timestamp, possible_reply, async_consensus_failure, read_within_uncertainty_interval, aborted, push_failure, unknownrestarts
cockroachdb.rangesrangesranges
cockroachdb.ranges_replication_problemunavailable, under_replicated, over_replicatedranges
cockroachdb.range_eventssplit, add, remove, mergeevents
cockroachdb.range_snapshot_eventsgenerated, applied_raft_initiated, applied_learner, applied_preemptiveevents
cockroachdb.rocksdb_read_amplificationreadsreads/query
cockroachdb.rocksdb_table_operationscompactions, flushesoperations
cockroachdb.rocksdb_cache_usageusedKiB
cockroachdb.rocksdb_cache_operationshits, missesoperations
cockroachdb.rocksdb_cache_hit_ratehit_ratepercentage
cockroachdb.rocksdb_sstablessstablessstables
cockroachdb.replicasreplicasreplicas
cockroachdb.replicas_quiescencequiescent, activereplicas
cockroachdb.replicas_leadersleaders, not_leaseholdersreplicas
cockroachdb.replicas_leaseholdersleaseholdersleaseholders
cockroachdb.queue_processing_failuresgc, replica_gc, replication, split, consistency, raft_log, raft_snapshot, time_series_maintenancefailures
cockroachdb.rebalancing_queriesavgqueries/s
cockroachdb.rebalancing_writesavgwrites/s
cockroachdb.timeseries_sampleswrittensamples
cockroachdb.timeseries_write_errorswriteerrors
cockroachdb.timeseries_write_byteswrittenKiB
cockroachdb.slow_requestsacquiring_latches, acquiring_lease, in_raftrequests
cockroachdb.code_heap_memory_usagego, cgoKiB
cockroachdb.goroutinesgoroutinesgoroutines
cockroachdb.gc_countgcinvokes
cockroachdb.gc_pausepauseus
cockroachdb.cgo_callscgocalls

Functions

This collector exposes real-time functions for interactive troubleshooting in the Top tab.

Top Queries

Retrieves and aggregates SQL statement performance metrics from CockroachDB crdb_internal.cluster_statement_statistics table.

This function queries cluster-wide statement statistics grouped by fingerprint (normalized query pattern). It provides aggregated metrics including execution counts, timing breakdowns, and row operation statistics.

Use cases:

  • Identify slow queries consuming the most total execution time
  • Find frequently executed queries that may benefit from optimization
  • Analyze row read/write patterns to detect inefficient queries

Query text is truncated at 4096 characters for display purposes.

AspectDescription
NameCockroachdb:top-queries
Require Cloudyes
PerformanceQueries the crdb_internal.cluster_statement_statistics table which aggregates data across the cluster:
• On busy clusters with high query throughput, this query may take longer
• Default limit of 500 rows balances usefulness with performance
SecurityQuery text may contain unmasked literal values including potentially sensitive data:
• Personal information in WHERE clauses or INSERT values
• Business data and internal identifiers
• Access should be restricted to authorized personnel only
AvailabilityAvailable when:
• The collector has successfully connected to CockroachDB
• The SQL user has VIEWACTIVITY or VIEWACTIVITYREDACTED privileges
• Returns HTTP 503 if the SQL connection cannot be established
• Returns HTTP 500 if the query fails
• Returns HTTP 504 if the query times out

Prerequisites

Grant VIEWACTIVITY access to cluster statement stats

The SQL user must have appropriate privileges to access statement statistics.

  1. Grant VIEWACTIVITY (shows full query text) or VIEWACTIVITYREDACTED (masks literals):

    GRANT SYSTEM VIEWACTIVITY TO netdata_user;
    -- OR for privacy:
    GRANT SYSTEM VIEWACTIVITYREDACTED TO netdata_user;
  2. On newer CockroachDB versions, access to crdb_internal may require:

    SET allow_unsafe_internals = on;
info
  • The collector automatically sets allow_unsafe_internals = on for the session when querying crdb_internal tables (required on newer versions)
  • VIEWACTIVITYREDACTED replaces literal values with underscores for privacy
  • Statement statistics are collected by default but can be disabled via cluster settings

Parameters

ParameterTypeDescriptionRequiredDefaultOptions
Filter ByselectSelect the primary sort column. Options include total time, executions, rows read, rows written, and more. Defaults to total time to focus on most resource-intensive queries.yestotalTime

Returns

Aggregated SQL statement statistics grouped by fingerprint. Each row represents a unique query pattern with cumulative metrics across all executions.

ColumnTypeUnitVisibilityDescription
Fingerprint IDstringhiddenUnique hash identifier for the normalized query pattern. Queries with identical structure but different literal values share the same fingerprint.
QuerystringNormalized SQL statement text with literals replaced. Truncated to 4096 characters.
DatabasestringDatabase name where the query was executed. Empty for queries without database context.
ApplicationstringApplication name that executed the query. Useful for identifying query sources across services.
Statement TypestringhiddenType of SQL statement (SELECT, INSERT, UPDATE, DELETE, etc.).
DistributedstringhiddenWhether the query used DistSQL execution (true/false). Distributed queries span multiple nodes.
Full ScanstringhiddenWhether the query performed a full table scan (true/false). Full scans may indicate missing indexes.
Implicit TxnstringhiddenWhether the statement ran in an implicit transaction (true/false).
VectorizedstringhiddenWhether the query used vectorized execution (true/false). Vectorized execution improves performance for analytical queries.
ExecutionsintegerTotal number of times this query pattern has been executed. High values indicate frequently run queries.
Total TimedurationmillisecondsCumulative service latency across all executions (mean time × executions). High values indicate queries consuming significant cluster resources.
Mean TimedurationmillisecondsAverage service latency per execution. Use this to compare typical performance across query patterns.
Run TimedurationmillisecondshiddenAverage time spent executing the query after planning. Excludes parse and plan time.
Plan TimedurationmillisecondshiddenAverage time spent generating the query execution plan. High values may indicate complex queries or stale statistics.
Parse TimedurationmillisecondshiddenAverage time spent parsing the SQL statement.
Rows ReadintegerTotal rows read across all executions. High values relative to rows returned suggest missing indexes or inefficient scans.
Rows WrittenintegerTotal rows written across all executions. Indicates write workload for INSERT, UPDATE, DELETE statements.
Rows ReturnedintegerTotal rows returned to clients across all executions. Compare with rows read to assess query efficiency.
Bytes ReadintegerhiddenTotal bytes read from storage across all executions. Indicates I/O load for the query pattern.
Max RetriesintegerhiddenMaximum number of automatic retries observed for this query pattern. High values indicate transaction contention.

Running Queries

Retrieves currently executing SQL statements across the CockroachDB cluster using SHOW CLUSTER STATEMENTS.

This function provides a real-time snapshot of all active queries across all nodes in the cluster, including their execution phase, duration, and associated metadata.

Use cases:

  • Identify long-running queries that may be blocking other operations
  • Monitor active workload distribution across the cluster
  • Debug stuck or slow queries in real-time

Query text is truncated at 4096 characters for display purposes.

AspectDescription
NameCockroachdb:running-queries
Require Cloudyes
PerformanceExecutes the SHOW CLUSTER STATEMENTS command which queries all nodes in the cluster:
• Lightweight operation with minimal overhead
• Returns only currently active queries, typically a small result set
SecurityQuery text may contain unmasked literal values including potentially sensitive data:
• Personal information in WHERE clauses or VALUES
• Session tokens or credentials
• Access should be restricted to authorized personnel only
AvailabilityAvailable when:
• The collector has successfully connected to CockroachDB
• The SQL user has VIEWACTIVITY or VIEWACTIVITYREDACTED privileges
• Returns HTTP 503 if the SQL connection cannot be established
• Returns HTTP 500 if the query fails
• Returns HTTP 504 if the query times out

Prerequisites

Grant VIEWACTIVITY access to system tables

The SQL user must have appropriate privileges to view running statements.

  1. Grant VIEWACTIVITY (shows full query text) or VIEWACTIVITYREDACTED (masks literals):

    GRANT SYSTEM VIEWACTIVITY TO netdata_user;
    -- OR for privacy:
    GRANT SYSTEM VIEWACTIVITYREDACTED TO netdata_user;
    info
    • SHOW CLUSTER STATEMENTS shows queries across all nodes, not just the connected node
    • VIEWACTIVITYREDACTED replaces literal values with underscores for privacy
    • Queries shown are point-in-time snapshots and may complete between retrieval and display

Parameters

ParameterTypeDescriptionRequiredDefaultOptions
Filter ByselectSelect the primary sort column. Defaults to elapsed time to show longest-running queries first.yeselapsedMs

Returns

Real-time snapshot of currently executing SQL statements across all cluster nodes. Each row represents a single active query.

ColumnTypeUnitVisibilityDescription
Query IDstringhiddenUnique identifier for this specific query execution. Can be used with CANCEL QUERY if needed.
QuerystringThe SQL statement currently being executed. Truncated to 4096 characters.
UserstringDatabase user executing the query. Useful for identifying workload by user.
ApplicationstringApplication name from the client connection. Helps identify which service is running the query.
Client AddressstringhiddenIP address of the client connection. Useful for identifying query sources.
Node IDstringhiddenCockroachDB node currently executing the query. Helps identify workload distribution.
Session IDstringhiddenSession identifier for the connection. Multiple queries may share a session.
PhasestringCurrent execution phase (executing, preparing, etc.). Indicates query progress.
DistributedstringhiddenWhether the query is using distributed execution across multiple nodes.
Start TimestringhiddenTimestamp when the query started executing.
ElapseddurationmillisecondsTime elapsed since query started. High values indicate long-running queries that may need investigation.

Alerts

The following alerts are available:

Alert nameOn metricDescription
cockroachdb_used_storage_capacity cockroachdb.storage_used_capacity_percentagestorage capacity utilization
cockroachdb_used_usable_storage_capacity cockroachdb.storage_used_capacity_percentagestorage usable space utilization
cockroachdb_unavailable_ranges cockroachdb.ranges_replication_problemnumber of ranges with fewer live replicas than needed for quorum
cockroachdb_underreplicated_ranges cockroachdb.ranges_replication_problemnumber of ranges with fewer live replicas than the replication target
cockroachdb_open_file_descriptors_limit cockroachdb.process_file_descriptorsopen file descriptors utilization (against softlimit)

Setup

You can configure the cockroachdb collector in two ways:

MethodBest forHow to
UIFast setup without editing filesGo to Nodes → Configure this node → Collectors → Jobs, search for cockroachdb, then click + to add a job.
FileIf you prefer configuring via file, or need to automate deployments (e.g., with Ansible)Edit go.d/cockroachdb.conf and add a job.
important

UI configuration requires paid Netdata Cloud plan.

Prerequisites

No action required.

Configuration

Options

The following options can be defined globally: update_every, autodetection_retry.

Config options
GroupOptionDescriptionDefaultRequired
Collectionupdate_everyData collection interval (seconds).10no
autodetection_retryAutodetection retry interval (seconds). Set 0 to disable.0no
TargeturlTarget endpoint URL.http://127.0.0.1:8080/_status/varsyes
timeoutHTTP request timeout (seconds).1no
Query FunctionsdsnSQL DSN used by top-queries and running-queries functions.no
sql_timeoutSQL query timeout (seconds) for query functions.1no
Limitstop_queries_limitMaximum number of rows returned by the top-queries and running-queries functions.500no
HTTP AuthusernameUsername for Basic HTTP authentication.no
passwordPassword for Basic HTTP authentication.no
bearer_token_filePath to a file containing a bearer token (used for Authorization: Bearer).no
TLStls_skip_verifySkip TLS certificate and hostname verification (insecure).nono
tls_caPath to CA bundle used to validate the server certificate.no
tls_certPath to client TLS certificate (for mTLS).no
tls_keyPath to client TLS private key (for mTLS).no
Proxyproxy_urlHTTP proxy URL.no
proxy_usernameUsername for proxy Basic HTTP authentication.no
proxy_passwordPassword for proxy Basic HTTP authentication.no
RequestmethodHTTP method to use.GETno
bodyRequest body (e.g., for POST/PUT).no
headersAdditional HTTP headers (one per line as key: value).no
not_follow_redirectsDo not follow HTTP redirects.nono
force_http2Force HTTP/2 (including h2c over TCP).nono
Virtual NodevnodeAssociates this data collection job with a Virtual Node.no

via UI

Configure the cockroachdb collector from the Netdata web interface:

  1. Go to Nodes.
  2. Select the node where you want the cockroachdb data-collection job to run and click the (Configure this node). That node will run the data collection.
  3. The Collectors → Jobs view opens by default.
  4. In the Search box, type cockroachdb (or scroll the list) to locate the cockroachdb collector.
  5. Click the + next to the cockroachdb collector to add a new job.
  6. Fill in the job fields, then click Test to verify the configuration and Submit to save.
    • Test runs the job with the provided settings and shows whether data can be collected.
    • If it fails, an error message appears with details (for example, connection refused, timeout, or command execution errors), so you can adjust and retest.

via File

The configuration file name for this integration is go.d/cockroachdb.conf.

The file format is YAML. Generally, the structure is:

update_every: 1
autodetection_retry: 0
jobs:
- name: some_name1
- name: some_name2

You can edit the configuration file using the edit-config script from the Netdata config directory.

cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
sudo ./edit-config go.d/cockroachdb.conf
Examples
Basic

An example configuration.

Config
jobs:
- name: local
url: http://127.0.0.1:8080/_status/vars

Top queries

Enable SQL query functions.

Config
jobs:
- name: local
url: http://127.0.0.1:8080/_status/vars
dsn: postgres://[email protected]:26257/defaultdb?sslmode=disable

HTTP authentication

Local server with basic HTTP authentication.

Config
jobs:
- name: local
url: http://127.0.0.1:8080/_status/vars
username: username
password: password

HTTPS with self-signed certificate

CockroachDB with enabled HTTPS and self-signed certificate.

Config
jobs:
- name: local
url: https://127.0.0.1:8080/_status/vars
tls_skip_verify: yes

Multi-instance

Note: When you define multiple jobs, their names must be unique.

Collecting metrics from local and remote instances.

Config
jobs:
- name: local
url: http://127.0.0.1:8080/_status/vars

- name: remote
url: http://203.0.113.10:8080/_status/vars

Troubleshooting

Debug Mode

Important: Debug mode is not supported for data collection jobs created via the UI using the Dyncfg feature.

To troubleshoot issues with the cockroachdb collector, run the go.d.plugin with the debug option enabled. The output should give you clues as to why the collector isn't working.

  • Navigate to the plugins.d directory, usually at /usr/libexec/netdata/plugins.d/. If that's not the case on your system, open netdata.conf and look for the plugins setting under [directories].

    cd /usr/libexec/netdata/plugins.d/
  • Switch to the netdata user.

    sudo -u netdata -s
  • Run the go.d.plugin to debug the collector:

    ./go.d.plugin -d -m cockroachdb

    To debug a specific job:

    ./go.d.plugin -d -m cockroachdb -j jobName

Getting Logs

If you're encountering problems with the cockroachdb collector, follow these steps to retrieve logs and identify potential issues:

  • Run the command specific to your system (systemd, non-systemd, or Docker container).
  • Examine the output for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.

System with systemd

Use the following command to view logs generated since the last Netdata service restart:

journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep cockroachdb

System without systemd

Locate the collector log file, typically at /var/log/netdata/collector.log, and use grep to filter for collector's name:

grep cockroachdb /var/log/netdata/collector.log

Note: This method shows logs from all restarts. Focus on the latest entries for troubleshooting current issues.

Docker Container

If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:

docker logs netdata 2>&1 | grep cockroachdb

Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.