Dashboard Annotation Filtering Based on Dashboard Variables

Hi everyone,

I’m working on a Grafana dashboard where all panels are driven by dashboard variables, and I’m trying to find a way to make panel annotations respect those variable values.

Dashboard Setup

I have a dashboard with variables like:

  • NodeId
  • Sensor
  • Channel

Each panel queries data based on the selected dashboard variables.

For example, my Temperature panel uses a query similar to:

WHERE NodeId = $NodeId

If I select:

  • NodeId = ABC

the panel displays only the time series for node ABC.

If I then change the variable to:

  • NodeId = CDF

the panel automatically refreshes and displays only the time series for node CDF.

This part works exactly as expected.

The Problem

Suppose I manually create an annotation on the Temperature panel while:

NodeId = ABC

For example:

  • Time: 2026-07-16 10:30
  • Description: “Temperature sensor calibration”

The annotation is successfully created.

However, when I later change the dashboard variable:

NodeId = CDF

the panel data correctly changes to node CDF, but the annotation line is still displayed on the panel.

When hovering over it, the description is also shown.

From the user’s perspective, this is misleading because the annotation belongs to node ABC, but it is now being displayed while viewing node CDF.

Expected Behavior

Ideally, annotations should be filtered using the current dashboard variables, similar to how the panel query is filtered.

For example:

When

NodeId = ABC

show only annotations created for ABC.

When

NodeId = CDF

show only annotations created for CDF.

Essentially, I would like annotations to behave like panel query results and automatically update when dashboard variables change.

What I Have Tried

I know Grafana supports:

  • Dashboard annotations
  • Panel annotations
  • Annotation queries
  • Tags

However, I couldn’t find a way to make manually created annotations automatically include dashboard variable values (such as NodeId) or filter themselves based on the currently selected variables.

My Questions

  1. Is it possible to make manual annotations respect dashboard variables?
  2. Can dashboard variables be attached automatically as annotation tags or metadata when creating an annotation?
  3. Is there any built-in support for filtering annotations using variables like $NodeId?
  4. Has anyone implemented a workaround for this?

Possible Workaround I’m Considering

One idea is to build a custom Grafana plugin or backend API where:

  • When a user creates an annotation, the current dashboard variable values (NodeId, Sensor, Channel, etc.) are also stored.
  • Instead of using Grafana’s built-in annotation storage directly, the dashboard queries a custom annotation source that filters annotations based on the currently selected variables.

Has anyone implemented something similar, or is there a better approach?

I’d appreciate any suggestions or recommended patterns for solving this problem.

Thanks!

When creating a manual annotation, add a tag matching the variable value (e.g. tag ABC when NodeId=ABC, tag CDF when NodeId=CDF).

Dashboard Settings → Annotations → Add annotation query:
Data source: -- Grafana --
Filter by: Tags
Tags: $NodeId
Enabled: must be checked

Disable the default Annotations & Alerts (Built-in query) → it shows all annotations unfiltered and will override the tag filtering if left on.

With NodeId=ABC selected → only the annotation tagged ABC shows.

With NodeId=CDF selected → only the annotation tagged CDF shows.

Filtering works correctly in both directions.

The main limitation is that Grafana doesn’t automatically attach the current dashboard variable values as annotation tags when creating manual annotations, so the tags have to be added manually. If automatic tagging is a requirement, then a custom plugin/backend (or another annotation source that stores the variable values) would still be needed. There’s an open feature request for automatic tagging: grafana/grafana#24674.