Grafana: Annotations and Links
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Checked on 2026-11-09 against Grafana 13.3.x.
To do this by hand, follow Rows, Tabs, Layouts, Annotations and Links.
A graph tells when a metric changed; it does not tell why. Annotations put the "why" on the same time axis: a deploy, a configuration change, a failover, an alert firing, a load test. Links answer the next question, "where do I look next?", by turning a panel or a data point into a pre-filtered jump to another dashboard, an Explore view, a runbook or a log search. Together they shorten the step between noticing an anomaly and finding its cause, which is most of the time in an incident. This page covers both. The panels that display annotations are described in Graphs and Charts; the variables that make links context-aware are in Variables.
Where annotations appear
Annotations are drawn as vertical lines (or shaded regions for ranges) with an icon at the bottom of a panel; hovering shows the description and tags. They are supported on Time series, State timeline and Candlestick panels. An annotation can come from the built-in store, an HTTP API call, or an annotation query against a data source.
Source: Grafana: Annotate visualizations.
Manual and region annotations
The dashboard must be saved and the built-in query Annotations & Alerts (Built-in) must be enabled (Edit > Dashboard options > Annotations, expand Hidden). Then:
-
Point annotation: click a data point and choose Add annotation, or Ctrl/Cmd-click anywhere in the panel; enter a description and optional tags and save.
-
Region annotation: Ctrl/Cmd-click and drag across the panel to mark a start and an end, for example a ten-minute load test.
-
Edit or delete: hover over the indicator at the bottom of the panel and use the pencil or trash icon.
Manual annotations are stored in Grafana, on the dashboard where they were created, under the -- Grafana -- data source (the only one that supports
creating annotations by hand). A consequence worth remembering: Save as gives the copy a new dashboard id, so its annotations
do not follow. A tag-based query (below) can recover them if they were tagged. Tag every annotation you expect to find again, with
at least the service and the event kind (deploy, incident, load-test).
Source: Add annotations and the built-in query described on the same page.
Annotations from automation
The most valuable annotations are written by the pipeline, not by people. The HTTP API creates one with POST /api/annotations; text is the only
required field, dashboardUID and panelId scope it (without them it is an organisation annotation), time and timeEnd are epoch milliseconds
(add timeEnd for a region) and tags is an array. The caller needs the annotations:create permission, typically through a service account token.
curl -X POST "http://localhost:3000/api/annotations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $GRAFANA_TOKEN" \
-d '{
"dashboardUID": "bookshelf-service-health",
"time": 1789000000000,
"tags": ["bookshelf", "deploy"],
"text": "Deploy bookshelf 1.8.2"
}'
Grafana 13 deprecates the /api routes in favour of /apis (the legacy routes keep working but are no longer updated), and a newer annotations API is rolling
out; treat the endpoint above as the current stable route and check the migration guide before building a long-lived integration. A CI job that calls
this endpoint after each deploy gives every graph a deploy marker, which is the cheapest way to answer "did this start with a release?".
Source: Grafana: Annotations HTTP API.
Annotation queries
An annotation query reads events from a data source and places them on selected panels. Add one with Edit > Add new element > Annotation query. The common settings are:
| Setting | Meaning |
|---|---|
Name |
Label of the toggle that shows or hides the events. |
Enabled |
Clear it to define the query without using it yet. |
Color |
Marker colour, to tell sources apart. |
Show annotation controls in |
Above dashboard (default), Controls menu or Hidden. |
Show in |
All panels, Selected panels or All panels except. |
Query |
Open query editor to choose a data source, or Use saved query (Enterprise and Cloud only). |
Test annotation query checks the query before saving. Saved annotation queries (Enterprise and Cloud) can be searched, starred, reused with their variables mapped to dashboard variables, and managed with the Grafana Terraform provider; they are limited to 1,000 and are not validated on save.
Source: Add annotation queries.
The built-in query and alert annotations
The built-in query shows the annotations stored on the current dashboard, including alert state history. A Grafana-managed alert rule that is linked to a dashboard panel therefore shows its state changes on that panel. The History page and the state history view of an alert rule provide the same data outside the dashboard; they need alert state history configured in Loki on OSS and Enterprise. See Monitoring Alerts and State History.
Source: Grafana: View alert state history.
Tag-based annotations across dashboards
Set Filter by to Tags on the -- Grafana -- data source to show annotations from any dashboard that carries the tags. All listed tags must match
unless Match any is enabled, and template variables work in the tag fields, so the same service variable that filters the panels also filters
the annotations. This is how one "deploys" annotation, created once on an overview dashboard, appears on every service dashboard.
On an externally shared dashboard a tag query with Display annotations enabled returns matches from all dashboards in the organisation, so do not
use tags that expose internal events on dashboards shared outside.
Source: Tag-based queries.
Prometheus annotations
A Prometheus annotation query is a PromQL expression; every sample returned becomes an event. Min step controls density (a larger step gives fewer annotations). Field mappings choose which field becomes Time, TimeEnd (for shaded regions), Title, Text and Tags. Template variables go inside the PromQL expression, not in the mappings. Typical Bookshelf queries are:
# a new build of the service started
changes(process_start_time_seconds{application="bookshelf"}[5m]) > 0
# alerts currently firing in Prometheus
ALERTS{alertstate="firing", application="bookshelf"}
The first expression assumes a metric that changes on restart (process_start_time_seconds is exposed by the Micrometer process metrics on the Bookshelf’s
/actuator/prometheus endpoint). Deployment markers are better driven by a build-info style metric or the API call above, because a restart is not always a release.
Source: Prometheus annotations.
Loki annotations
A Loki annotation query selects log lines with LogQL and turns each into an event. Title and Text accept label templates written with double braces, Tags
is a comma-separated list of label keys (if empty, the stream labels are used), and if Text is empty the log line itself is shown. To reference a parsed
field that is not an indexed label, add a parser such as logfmt or json to the query:
{app="deploy-bot"} |= `deployed` | logfmt
Pair that with Title {{app}} deployed, Tags app,env and Text {{message}}.
Source: Loki annotations.
Time regions
Set the query type to Time regions to shade recurring periods such as business hours or a maintenance window, defined by weekday and time with the dashboard time zone as default; the Advanced toggle accepts a cron expression. Regions give the eye a reference ("the spike is outside business hours") without any data source.
Source: Time regions.
The Annotations list panel
The Annotations list panel shows annotations as a table of events. Options include the query filter (All dashboards or This dashboard), the time range (None or This dashboard), tags, a result limit (default 10), and the click behaviour: link target Panel (default) or Dashboard, with Time before and Time after (default 10 minutes) around the event. Put it next to the main graphs as a short change log.
Source: Grafana: Annotations list.
Dashboard links
Dashboard links appear at the top of the dashboard (or in the controls menu). In Edit > Dashboard options > View all settings > Links add a link of type
Dashboards (links to other dashboards, optionally limited by With tags, optionally Show as dropdown) or Link (any URL, with tooltip and icon). Two options carry
the viewer’s context: Include current time range and Include current template variable values, the latter passing values to variables of the same name in the target
dashboard. Tags are a good way to keep a "related dashboards" menu current without editing every dashboard: tag each service dashboard bookshelf
and the link picks up new ones by itself.
Source: Dashboard links.
Panel links
A panel link is a titled URL shown beside the panel title; its URL may contain variables and the time parameters from, to, time and time.window. Add it from the
panel editor under Panel options > Panel links. Typical uses are a link from the "5xx ratio" panel to the runbook, and from the latency panel to the Traces
drilldown.
Source: Panel links.
Data links
A data link acts on one series or value, so it can carry what the user clicked. It is configured in Data links and actions in the panel editor, with a title, a URL and the
options Open in a new tab and One click (one per panel, on supporting visualizations). In the URL field, typing $ lists the available variables. The reference includes:
| Variable | Value |
|---|---|
|
The current dashboard time range as URL parameters. |
|
Start and end times. |
|
Name of the series. |
|
Field name; display name for renamed fields. |
|
Value of a label (use |
|
Raw, numeric and text representation of the value, and its timestamp in Unix milliseconds. |
|
Value of another field in the same row. |
|
All current dashboard variables. |
Time-range and value variables do not add ? or &, so write the query string yourself. A link from the route table back to the same dashboard, filtered by the clicked row, is:
/d/bookshelf-service-health?orgId=1&${__url_time_range}&${__all_variables}&var-route=${__data.fields["uri"]}
Use the variable name, not its label, in var- parameters, and remember that an All selection becomes var-x=All. Put the all-variables placeholder before a variable defined by hand in the same
link, as in the example.
Source: Grafana: Configure data links.
What can go wrong
-
Annotations missing after Save as or import. They belong to the original dashboard id; use tags.
-
The same event drawn many times. A Prometheus query with a small Min step returns many samples; raise the step or use
changes(...) > 0. -
Annotations hidden. The toggle above the dashboard is off, or Show in excludes the panel.
-
A link opens the wrong context. The time range or variables were not included, or the URL used a variable label instead of its name.
-
Tag queries leak events on externally shared dashboards (see above) and on dashboards whose viewers should not see other teams' changes.
Verify in the lab
-
On "Bookshelf service health" Ctrl/Cmd-click a time series panel, add a region annotation tagged
bookshelf, load-testand confirm it shows on the panel after a reload. -
Run the
curlcall above with a service account token (adjustingdashboardUIDto the dashboard’s UID) and confirm the marker appears. -
Add a tag query for
bookshelfon a second dashboard and confirm the same marker shows there. -
Fire the "high 5xx ratio" lab alert and check that its state changes appear through the built-in query.
-
Click a data link and confirm the target dashboard opens with the same time range and the clicked route selected.
In the books
Salituro (Learn Grafana 10.x, chapter 10) covers dashboard links, tagging, annotating the graph panel, tag-based annotation queries and Elasticsearch annotation queries, and McCollam (Getting
Started with Grafana, chapter 7) covers links and panel links in the workflow from overview to detail. The Graph panel they annotate was replaced by the Time series panel, region annotations,
time regions and Loki and Prometheus annotation mappings arrived later, links are now added from the dashboard edit sidebar, and the HTTP API is moving from /api to /apis. The advice (annotate
events that explain changes, link overview to detail) remains valid.