Operations 6 min read

How to Add Interactive Variables to Grafana Dashboards for Dynamic Monitoring

This guide explains what Grafana variables are, why they act like a dashboard control knob, and provides step‑by‑step instructions with screenshots and JSON examples for creating data‑source, business‑tag, and JSON‑file variables to build interactive monitoring dashboards.

Linux Ops Smart Journey
Linux Ops Smart Journey
Linux Ops Smart Journey
How to Add Interactive Variables to Grafana Dashboards for Dynamic Monitoring

What are Grafana Variables?

Variables are dynamic parameters in Grafana that let you change the data displayed on a dashboard without editing each panel query, using dropdowns or input fields.

Tip: Think of them as a control knob for the whole dashboard.

Browser Configuration Variable

To create a data‑source variable:

Select Data source as the variable type.

Set Name (used in PromQL).

Set Label for panel display.

Choose Prometheus as the data source type.

(Optional) Add a regex filter, e.g. /^(?!default).*/, to exclude the default source.

Resulting dashboard screenshot:

Business Tag Variable

To create a query variable for business tags:

Select Query as the variable type.

Set Name and Label .

Choose the data source ${datasource}.

Set Query type to retrieve label values.

Specify the label (e.g., instance) and metric.

(Optional) Enable Multi‑value and Include All options.

Resulting dashboard screenshot:

JSON File Variable

You can also define variables in a JSON dashboard file. Example snippets show the basic dashboard structure and how to embed a datasource variable and a business‑tag variable in the templating.list array.

{
  "uid": "",
  "title": "study dashboard",
  "tags": [],
  "timezone": "CST",
  "editable": false,
  "panels": [],
  "refresh": false,
  "time": {"from": "now-3h", "to": "now"},
  "templating": {"list": []}
}
{
  "uid": "230e0fc0f0544d1b9e7910f5e27f9a0c",
  "title": "study dashboard",
  "tags": [],
  "timezone": "CST",
  "editable": false,
  "panels": [],
  "refresh": false,
  "time": {"from": "now-3h", "to": "now"},
  "templating": {
    "list": [
      {
        "type": "datasource",
        "name": "datasource",
        "label": "Datasource",
        "query": "prometheus",
        "regex": "/^(?!default).*/"
      }
    ]
  }
}
{
  "uid": "230e0fc0f0544d1b9e7910f5e27f9a0c",
  "title": "study dashboard",
  "tags": [],
  "timezone": "CST",
  "editable": false,
  "panels": [],
  "refresh": false,
  "time": {"from": "now-3h", "to": "now"},
  "templating": {
    "list": [
      {
        "type": "datasource",
        "name": "datasource",
        "label": "Datasource",
        "query": "prometheus",
        "regex": "/^(?!default).*/"
      },
      {
        "type": "query",
        "name": "instance",
        "label": "host",
        "datasource": {"uid": "${datasource}"},
        "query": "label_values(node_memory_Active_bytes, instance)",
        "includeAll": true,
        "multi": true
      }
    ]
  }
}

Conclusion

After reading this article you should understand the basics of Grafana variables and be able to build dashboards with interactive, dynamic data selection.

MonitoringoperationsPrometheusDashboardGrafanaVariables
Linux Ops Smart Journey
Written by

Linux Ops Smart Journey

The operations journey never stops—pursuing excellence endlessly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.