CockroachDB annotations
Annotations let you overlay event data from CockroachDB on your Grafana dashboard panels. They appear as vertical lines or shaded regions on time series visualizations, giving you context about what happened at a specific point in time. Use annotations to correlate metrics with events like deployments, incidents, configuration changes, or schema migrations.
Before you begin
- Configure the CockroachDB data source.
- Familiarize yourself with Grafana annotations.
Create an annotation query
To add a CockroachDB annotation query to a dashboard:
- Navigate to Dashboard settings > Annotations.
- Click Add annotation query.
- Give the annotation a descriptive name (for example, “Deployments” or “Incidents”).
- Select the CockroachDB data source.
- Enter a SQL query that returns the required columns (refer to Annotation query format).
- Optionally, set a color to distinguish this annotation from others.
- Click Apply.
Annotations from the query appear on all time series panels in the dashboard. You can toggle them on and off using the annotation controls at the top of the dashboard.
Annotation query format
Annotation queries must return specific columns for Grafana to render them correctly.
Note
Always include
$__timeFilterin your annotation query’sWHEREclause. Without it, the query returns all annotations regardless of the dashboard time range, which can slow down dashboard loading.
Annotation query examples
The following examples show common annotation patterns for CockroachDB dashboards.
Deployments
Mark application deployments on your dashboards:
SELECT
deployed_at AS time,
CONCAT('Deployed ', version, ' to ', environment) AS text,
environment AS tags
FROM deployments
WHERE $__timeFilter(deployed_at)
ORDER BY deployed_at ASCIncidents
Overlay incident windows as shaded regions showing start and end times:
SELECT
started_at AS time,
resolved_at AS timeEnd,
CONCAT(severity, ': ', description) AS text,
severity AS tags
FROM incidents
WHERE $__timeFilter(started_at)
ORDER BY started_at ASCSchema migrations
Track database schema changes:
SELECT
completed_at AS time,
CONCAT('Migration: ', description) AS text,
'migration' AS tags
FROM schema_migrations
WHERE $__timeFilter(completed_at)
ORDER BY completed_at ASCConfiguration changes
Annotate when application or cluster configuration was modified:
SELECT
changed_at AS time,
CONCAT(setting_name, ' changed from ', old_value, ' to ', new_value) AS text,
CONCAT(setting_name, ',', changed_by) AS tags
FROM config_audit_log
WHERE $__timeFilter(changed_at)
ORDER BY changed_at ASCCockroachDB cluster events
Use CockroachDB’s internal event log to annotate cluster-level events like node joins, restarts, and zone config changes:
SELECT
timestamp AS time,
CONCAT(event_type, ': ', info) AS text,
event_type AS tags
FROM system.eventlog
WHERE $__timeFilter(timestamp)
ORDER BY timestamp ASCFilter annotations by tag
If you have multiple annotation queries on a dashboard, use tags to control which annotations are visible.
- In the annotation query, return a
tagscolumn with meaningful values (for example,'production','staging'). - At the top of the dashboard, use the annotation toggle to show or hide specific annotation sources.
- In individual panels, you can filter annotations by tag under Panel settings > Annotations.
This lets you keep a clean view while still having all event data available when you need it.



