docs/sources/datasources/influxdb/annotations/index.md
Annotations overlay event data on your dashboard graphs, helping you correlate events with metrics. You can use InfluxDB as a data source for annotations to display events such as deployments, alerts, or other significant occurrences on your visualizations.
For general information about annotations, refer to Annotate visualizations.
Before creating InfluxDB annotations, ensure you have:
To add an InfluxDB annotation to your dashboard:
For InfluxQL-configured data sources, write an InfluxQL query in the InfluxQL Query field. Your query must include WHERE $timeFilter to scope the results to the dashboard's time range.
Field mappings tell Grafana which InfluxDB columns contain the annotation data. If your query returns only one column, you don't need to enter anything in the field mapping fields.
| Field | Description |
|---|---|
| Text | The column containing the annotation description displayed when you hover over the annotation. |
| Tags | The column containing tags for the annotation. The value can be a comma-separated string. Tags help categorize and filter annotations. |
| TimeEnd | The column containing an end time for range annotations. Range annotations display as a shaded region on the graph instead of a single vertical line. |
The following query retrieves deployment events and displays them as annotations:
SELECT title, description
FROM events
WHERE $timeFilter
ORDER BY time ASC
To display events with duration as shaded regions:
SELECT description, tags, end_time
FROM maintenance_windows
WHERE $timeFilter
ORDER BY time ASC
Configure the field mappings as follows:
descriptiontagsend_timeFor Flux-configured data sources, annotations use the standard Flux query editor. Write a Flux query that returns data frames with time, text, and optional tag fields.
from(bucket: "events")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "deployments")
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
Grafana processes the resulting data frames as annotation events. Ensure the query returns a _time column and at least one text column.
SQL-configured data sources (InfluxDB 3.x) use the standard Grafana annotation query editor. Write an SQL query that returns a time column and at least one text column. Use the $__timeFilter(time) macro to scope results to the dashboard time range.
SELECT time, title, description
FROM events
WHERE $__timeFilter(time)
ORDER BY time ASC
To display events with duration as shaded regions, return both a start time and an end time:
SELECT time, end_time, description, tags
FROM maintenance_windows
WHERE $__timeFilter(time)
ORDER BY time ASC
Configure the field mappings:
descriptiontagsend_timeYou can use template variables in your annotation queries to filter annotations based on dashboard variable selections. For example:
SELECT title, description
FROM events
WHERE $timeFilter AND environment = '$environment'
ORDER BY time ASC
If your annotations aren't appearing or you encounter errors, refer to Troubleshoot InfluxDB data source issues.