Amazon Redshift annotations
Annotations let you overlay event information on top of graphs. You can use SQL queries against your Redshift data to mark important events, deployments, incidents, or other time-based occurrences directly on your dashboard panels.
For general information about annotations, refer to Annotate visualizations.
Before you begin
- Configure the Amazon Redshift data source.
- Verify that your Redshift database contains the event data you want to annotate.
Add an annotation query
To add an annotation query to a dashboard:
- Open the dashboard you want to annotate.
- Click Dashboard settings (the gear icon).
- Select Annotations in the left menu.
- Click Add annotation query.
- Select the Amazon Redshift data source.
- Enter an SQL query that returns the required columns.
- Click Apply.
Column conventions
Your annotation query must return specific columns for Grafana to render annotations correctly. The annotation query editor provides the same SQL editor, resource selectors, and macro support as the standard query editor.
Example annotation query
The following query creates annotations for high-humidity events:
SELECT
time AS time,
environment AS tags,
humidity AS text
FROM
$__table
WHERE
$__timeFilter(time) AND humidity > 95This query:
- Uses the
$__tablemacro to reference the table selected in the resource selector. - Filters results to the dashboard time range with
$__timeFilter(time). - Creates an annotation for each record where humidity exceeds 95.
- Tags each annotation with the
environmentvalue.
Region annotations
To create annotations that span a time range (region annotations), include both a time and timeend column:
SELECT
start_time AS time,
end_time AS timeend,
description AS text,
severity AS tags
FROM
incidents
WHERE
$__timeFilter(start_time)Region annotations display as shaded areas on graphs, useful for marking maintenance windows, incidents, or other events with a duration.
Note
Annotation queries run asynchronously through the Redshift Data API, just like regular queries. Complex annotation queries or queries that return large result sets can affect dashboard load times.
Use template variables in annotations
You can reference template variables in your annotation queries to make them dynamic:
SELECT
event_time AS time,
event_description AS text,
event_type AS tags
FROM
events
WHERE
$__timeFilter(event_time) AND region = '${region}'

