---
title: "Variables | Grafana documentation"
description: "Add variables to metric queries and panel titles to create interactive and dynamic dashboards"
---

# Variables

> **Note:** Looking for prebuilt Grafana dashboards? [Check out our full library of dashboards and more →](/grafana/dashboards/?pg=docs-grafana-next-visualizations-dashboards-variables)

A variable is a placeholder for a value. When you change the value, the element using the variable will change to reflect the new value.

Variables are displayed as drop-down lists (or in some cases text fields) at the top of the dashboard. These drop-down lists make it easy to update the variable value and thus change the data being displayed in your dashboard.

For example, if you needed to monitor several servers, you *could* make a dashboard for each server. Or you could create one dashboard and use panels with variables like this one, where you can change the server using the variable selector:

[](/media/docs/grafana/dashboards/screenshot-selected-variables-v12.png)

Variables allow you to create more interactive dashboards. Instead of hard-coding things like server, application, and sensor names in your metric queries, you can use variables in their place. They’re useful for administrators who want to allow Grafana viewers to adjust visualizations without giving them full editing permissions.

Using variables also allows you to single-source dashboards. If you have multiple identical data sources or servers, you can make one dashboard and use variables to change what you are viewing. This simplifies maintenance and upkeep enormously.

You can use variables in:

- Data source queries
- [Panel repeating options](/docs/grafana/next/panels-visualizations/configure-panel-options/#configure-repeating-panels)
- [Dashboard and panel links](/docs/grafana/next/dashboards/build-dashboards/manage-dashboard-links/)
- Titles
- Descriptions
- [Transformations](/docs/grafana/next/panels-visualizations/query-transform-data/transform-data/)

To see variable settings, navigate to **Dashboard Settings &gt; Variables**. Click a variable in the list to see its settings.

Give it a try using Grafana Play

With Grafana Play, you can explore and see how it works, learning from practical examples to accelerate your development. This feature can be seen on [Templating - Interactive dashboard](https://play.grafana.org/goto/B9Xog68Hg?orgId=1).

[Try it](https://play.grafana.org/goto/B9Xog68Hg?orgId=1)

## Template variables

A *template* is any query that contains a variable. Queries with text that starts with `$` are templates.

> Note
> 
> In our documentation and in the application, we typically simply refer to a *template query* as a *query*, but we often use the terms *variable* and *template variable* interchangeably.

For example, if you were administering a dashboard to monitor several servers, it could have panels that use template queries like this one:

text ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```text
groupByNode(movingAverage(apps.$app.$server.counters.requests.count, 10), 2, 'sum')
```

The following image shows a panel in edit mode using the query:

[](/media/docs/grafana/dashboards/screenshot-template-query-v12.1.png)

### Variables in URLs

By default, variable values are synced to the URL using [query parameter syntax](/docs/grafana/latest/dashboards/variables/variable-syntax/#query-parameters), `var-<varname>=value`. For example:

text ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```text
https://play.grafana.org/d/HYaGDGIMk/templating-global-variables-and-interpolation?orgId=1&from=now-6h&to=now&timezone=utc&var-Server=CCC&var-MyCustomDashboardVariable=Hello%20World%21
```

In the preceding example, the variables and values are `var-Server=CCC` and `var-MyCustomDashboardVariable=Hello%20World%21`.

You can prevent a variable from being synced to the URL by setting `skipUrlSync` to `true` in the variable definition within the dashboard JSON model. When set, the variable value won’t appear as a `var-` query parameter in the URL.

This is useful when you want to keep URLs clean, prevent users from overriding a variable value through the URL, or avoid exposing sensitive values in shared links.

> Note
> 
> Constant variables have `skipUrlSync` set to `true` by default, since their value is fixed and not intended to be changed through the URL.

## Additional examples

The following dashboards in Grafana Play provide examples of template variables:

- [Templating - Repeated panels](https://play.grafana.org/goto/yfZOReUNR?orgId=1) - Using query variables to control how many panels appear in a dashboard.
- [Templating - Nested Variables Drilldown](https://play.grafana.org/d/testdata-nested-variables-drilldown/) - Demonstrates how changing one variable value can change the values available in a nested variable.
- [Templating - Global variables and interpolation](https://play.grafana.org/d/HYaGDGIMk/) - Shows you how the syntax for Grafana variables works.

## Next steps

The following topics describe how to add and manage variables in your dashboards:

- [Add variables](/docs/grafana-cloud/visualizations/dashboards/variables/add-template-variables/)
- [Manage and inspect variables](/docs/grafana-cloud/visualizations/dashboards/variables/inspect-variable/)
- [Variable syntax](/docs/grafana-cloud/visualizations/dashboards/variables/variable-syntax/)
