Add a variable
Open the editor, select Settings → Variables, and add a variable:
Save the dashboard to keep the variable.
Types
Query variables
A query variable reads its values in the current time range. Choose the Query type:
The first value becomes the default. A query can use another variable, for example an SQL statement
with
WHERE environment = '$env', so choosing an environment narrows the services.
Use a variable
Write$name or ${name} in a query, a panel title, a text element, or a link. The braces are needed
when letters follow the name, for example ${service}_errors. A variable with several values gives
them joined with commas; add a format to change that:
For example, a PromQL panel
sum(rate(http_requests_total{service=~"${service:regex}"}[5m])) follows
the selected services.
Values in the address
The chosen values are kept in the address of the dashboard asvar-<name>=<value>, repeated for each
value of a multi-value variable. Copy the address, or build a link with these parameters, to open the
dashboard with the same choice. A data link can pass the
variables on as well.