IBM Db2 annotations
Annotations mark points in time on your dashboard panels with events or notes. The IBM Db2 data source uses the built-in Grafana SQL annotation support, so you can populate annotations from any query that runs against your IBM Db2 database.
Before you begin
Before you create annotations, ensure you have:
- Configured the IBM Db2 data source
- A table or view that contains event data with a timestamp column
Create an annotation query
To create an annotation query:
- Open your dashboard, click Edit, then click Options (gear icon).
- Click Annotations in the left menu.
- Click Add annotation query.
- Enter a name for the annotation query.
- Click Open query editor, then select your IBM Db2 data source.
- Enter a SQL query that returns the required columns.
- Click Apply to save the annotation query.
Annotation query requirements
Grafana maps the result set to annotations by column name. Alias your columns to these names so Grafana can map them correctly:
Order the results by the time column so annotations render in chronological order.
Note
The
timeandtimeendcolumns must beTIMESTAMPvalues. If your column is aDATE, the plugin converts it to aTIMESTAMPautomatically. If it’s aTIME, cast it to aTIMESTAMPin the query. The IBM Db2 data source doesn’t support SQL macros such as$__timeFilter, so filter with standard Db2 SQL or template variables.
Examples
The following examples use placeholder table names. Replace them with your own schema.
Point-in-time annotation
Mark each event with a single timestamp, a description, and tags:
SELECT
event_time AS time,
event_description AS text,
event_category AS tags
FROM events
ORDER BY event_timeRegion annotation
Include a timeend column to highlight a time range, such as a deployment or maintenance window:
SELECT
start_time AS time,
end_time AS timeend,
deployment_name AS text,
'deployment' AS tags
FROM deployments
ORDER BY start_timeFilter annotations with a template variable
Use a template variable to show only the events you care about:
SELECT
event_time AS time,
event_description AS text,
event_category AS tags
FROM events
WHERE event_category = '$category'
ORDER BY event_time

