grafana/docs/sources/variables/syntax.md
Christopher Moyer a568d421f8
Docs: Setup refactor (#49739)
* builds out refactored setup topics

* Automatically fix some relrefs with mv-manager

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Use refs for tutorials content which is outside of this repository

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Manually fix complicated relrefs

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* consolidates team sync and db encryption topics

* Fix relrefs

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* updates setup index file

* Convert TOML to YAML

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Add current alias for new alerting content

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Add current aliases to new setup-grafana and configure-security pages

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>

* moves saml docs, updates order in TOC

* Manually fix relrefs

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* added usage insights topics, adjusted weights

* corrected relrefs

* Fix relrefs broken in rebase

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-06-02 11:57:22 -05:00

33 lines
1.5 KiB
Markdown

---
aliases:
- /docs/grafana/latest/reference/templating/
- /docs/grafana/latest/variables/syntax/
keywords:
- grafana
- templating
- documentation
- guide
- template
- variable
title: Variable syntax
weight: 100
---
# Variable syntax
Panel titles and metric queries can refer to variables using two different syntaxes:
- `$varname`
This 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]({{< relref "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]({{< relref "advanced-variable-format-options/" >}}).