Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana/v8.0/variables/syntax.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana/v8.0/variables/syntax/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Variable syntax
Panel titles and metric queries can refer to variables using two different syntaxes:
$varnameThis syntax is easy to read, but it does not allow you to use a variable in the middle of a word. Example: apps.frontend.$server.requests.count${var_name}Use this syntax when you want to interpolate a variable in the middle of an expression.${var_name:<format>}This format gives you more control over how Grafana interpolates values. Refer to Advanced variable format options for more detail on all the formatting types.[[varname]]Do not use. Deprecated old syntax, will be removed in a future release.
Before queries are sent to your data source the query is interpolated, meaning the variable is replaced with its current value. During interpolation, the variable value might be escaped in order to conform to the syntax of the query language and where it is used. For example, a variable used in a regex expression in an InfluxDB or Prometheus query will be regex escaped. Read the data source specific documentation topic for details on value escaping during interpolation.
For advanced syntax to override data source default formatting, refer to Advanced variable format options.