<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Variables on Grafana Labs</title><link>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/</link><description>Recent content in Variables on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v12.4/visualizations/dashboards/variables/index.xml" rel="self" type="application/rss+xml"/><item><title>Add variables</title><link>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/add-template-variables/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/add-template-variables/</guid><content><![CDATA[&lt;h1 id=&#34;add-variables&#34;&gt;Add variables&lt;/h1&gt;
&lt;!-- vale Grafana.Spelling = NO --&gt;
&lt;p&gt;The following table lists the types of variables shipped with Grafana.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Variable type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Query&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. &lt;a href=&#34;#add-a-query-variable&#34;&gt;Add a query variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Custom&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Define the variable options manually using a comma-separated list. &lt;a href=&#34;#add-a-custom-variable&#34;&gt;Add a custom variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Text box&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Display a free text input field with an optional default value. &lt;a href=&#34;#add-a-text-box-variable&#34;&gt;Add a text box variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Constant&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Define a hidden constant. &lt;a href=&#34;#add-a-constant-variable&#34;&gt;Add a constant variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Data source&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Quickly change the data source for an entire dashboard. &lt;a href=&#34;#add-a-data-source-variable&#34;&gt;Add a data source variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Interval&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Interval variables represent time spans. &lt;a href=&#34;#add-an-interval-variable&#34;&gt;Add an interval variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Ad hoc filters&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). &lt;a href=&#34;#add-ad-hoc-filters&#34;&gt;Add ad hoc filters&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Switch&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Display a switch that allows you to toggle between two configurable values for enabled and disabled states. &lt;a href=&#34;#add-a-switch-variable&#34;&gt;Add a switch variable&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Global variables&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Built-in variables that can be used in expressions in the query editor. Refer to &lt;a href=&#34;#global-variables&#34;&gt;Global variables&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Chained variables&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Variable queries can contain other variables. Refer to &lt;a href=&#34;#chained-variables&#34;&gt;Chained variables&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;p&gt;You must enter general options for any type of variable that you create.
To create a variable, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Edit&lt;/strong&gt; in the top-right corner of the dashboard.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Settings&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;strong&gt;Variables&lt;/strong&gt; tab.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Add variable&lt;/strong&gt;, or if there are already existing variables, &lt;strong&gt;&#43; New variable&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose an option in the &lt;strong&gt;Select variable type&lt;/strong&gt; drop-down list.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for the variable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) In the &lt;strong&gt;Label&lt;/strong&gt; field, enter the display name for the variable drop-down list.&lt;/p&gt;
&lt;p&gt;If you don&amp;rsquo;t enter a display name, then the drop-down list label is the variable name.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose a &lt;strong&gt;Display&lt;/strong&gt; option:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Above dashboard&lt;/strong&gt; - The variable drop-down list displays above the dashboard with the variable &lt;strong&gt;Name&lt;/strong&gt; or &lt;strong&gt;Label&lt;/strong&gt; value. This is the default.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Above dashboard, label hidden&lt;/strong&gt; - The variable drop-down list displays above the dashboard, but without showing the name of the variable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Controls menu&lt;/strong&gt; - The variable is displayed in the dashboard controls menu instead of above the dashboard. The dashboard controls menu appears as a button in the dashboard toolbar.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hidden&lt;/strong&gt; - No variable drop-down list is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click one of the following links to complete the steps for adding your selected variable type:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#add-a-query-variable&#34;&gt;Query&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-a-custom-variable&#34;&gt;Custom&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-a-text-box-variable&#34;&gt;Textbox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-a-constant-variable&#34;&gt;Constant&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-a-data-source-variable&#34;&gt;Data source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-an-interval-variable&#34;&gt;Interval&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-ad-hoc-filters&#34;&gt;Ad hoc filters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#add-a-switch-variable&#34;&gt;Switch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- vale Grafana.Spelling = YES --&gt;
&lt;h3 id=&#34;variable-best-practices&#34;&gt;Variable best practices&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Variable drop-down lists are displayed in the order in which they&amp;rsquo;re listed in the &lt;strong&gt;Variables&lt;/strong&gt; in dashboard settings, so put the variables that you will change often at the top, so they will be shown first (far left on the dashboard).&lt;/li&gt;
&lt;li&gt;By default, variables don&amp;rsquo;t have a default value. This means that the topmost value in the drop-down list is always preselected. If you want to pre-populate a variable with an empty value, you can use the following workaround in the variable settings:
&lt;ol&gt;
&lt;li&gt;Select the &lt;strong&gt;Include All Option&lt;/strong&gt; checkbox.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Custom all value&lt;/strong&gt; field, enter a value like &lt;code&gt;.&#43;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;add-a-query-variable&#34;&gt;Add a query variable&lt;/h2&gt;
&lt;p&gt;Query variables enable you to write a data source query that can return a list of metric names, tag values, or keys. For example, a query variable might return a list of server names, sensor IDs, or data centers. The variable values change as they dynamically fetch options with a data source query.&lt;/p&gt;
&lt;p&gt;Query variables are generally only supported for strings. If your query returns numbers or any other data type, you might need to convert them to strings to use them as variables. For the Azure data source, for example, you can use the &lt;a href=&#34;https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tostringfunction&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;tostring&lt;/code&gt;&lt;/a&gt; function for this purpose.&lt;/p&gt;
&lt;p&gt;Query expressions can contain references to other variables and in effect create linked variables. Grafana detects this and automatically refreshes a variable when one of its linked variables change.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Query expressions are different for each data source. For more information, refer to the documentation for your 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/&#34;&gt;data source&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Query options&lt;/strong&gt; section of the page, select a target data source in the &lt;strong&gt;Data source&lt;/strong&gt; drop-down list.
You can also click &lt;strong&gt;Open advanced data source picker&lt;/strong&gt; to see more options, including adding a data source (Admins only).
For more information about data sources, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/#add-a-data-source&#34;&gt;Add a data source&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Query type&lt;/strong&gt; drop-down list, select an option and fill in the query fields accordingly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The query field varies according to your data source. Some data sources have custom query editors.&lt;/li&gt;
&lt;li&gt;Each data source defines how the variable values are extracted. The typical implementation uses every string value returned from the data source response as a variable value. Make sure to double-check the documentation for the data source.&lt;/li&gt;
&lt;li&gt;Some data sources let you provide custom &amp;ldquo;display names&amp;rdquo; for the values. For instance, the PostgreSQL, MySQL, and Microsoft SQL Server plugins handle this by looking for fields named &lt;code&gt;__text&lt;/code&gt; and &lt;code&gt;__value&lt;/code&gt; in the result. Other data sources may look for &lt;code&gt;text&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt; or use a different approach. Always remember to double-check the documentation for the data source.&lt;/li&gt;
&lt;li&gt;If you need more room in a single input field query editor, then hover your cursor over the lines in the lower right corner of the field and drag downward to expand.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) In the &lt;strong&gt;Regex&lt;/strong&gt; field, type a regular expression to filter or capture specific parts of the names returned by your data source query. To see examples, refer to &lt;a href=&#34;#filter-variables-with-regex&#34;&gt;Filter variables with a regular expression&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under &lt;strong&gt;Apply regex to&lt;/strong&gt;, select &lt;strong&gt;Variable value&lt;/strong&gt; or &lt;strong&gt;Display text&lt;/strong&gt; to choose where the regex pattern is applied. The default is &lt;strong&gt;Variable value&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Sort&lt;/strong&gt; drop-down list, select the sort order for values to be displayed in the dropdown list. The default option, &lt;strong&gt;Disabled&lt;/strong&gt;, means that the order of options returned by your data source query is used.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under &lt;strong&gt;Refresh&lt;/strong&gt;, select when the variable should update options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;On dashboard load&lt;/strong&gt; - Queries the data source every time the dashboard loads. This slows down dashboard loading, because the variable query needs to be completed before dashboard can be initialized.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;On time range change&lt;/strong&gt; - Queries the data source every time the dashboard loads and when the dashboard time range changes. Use this option if your variable options query contains a time range filter or is dependent on the dashboard time range.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) In the &lt;strong&gt;Static options&lt;/strong&gt; section of the page, toggle on the &lt;strong&gt;Use static options&lt;/strong&gt; switch to add custom options in addition to the query results:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make entries in the &lt;strong&gt;Value&lt;/strong&gt; and &lt;strong&gt;Display text&lt;/strong&gt; fields.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;&#43; Add new option&lt;/strong&gt; to add another static option.&lt;/li&gt;
&lt;li&gt;Repeat these steps as many times as needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Configure the settings in the &lt;a href=&#34;#configure-variable-selection-options&#34;&gt;Selection Options&lt;/a&gt; section:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Multi-value&lt;/strong&gt; - Enables multiple values to be selected at the same time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Allow custom values&lt;/strong&gt; - Enables users to add custom values to the list.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include All option&lt;/strong&gt; - Enables an option to include all variables. Enter a value in the &lt;strong&gt;Custom all value&lt;/strong&gt; field to set your own &amp;ldquo;all&amp;rdquo; option.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Preview of values&lt;/strong&gt; section, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-a-custom-variable&#34;&gt;Add a custom variable&lt;/h2&gt;
&lt;p&gt;Use a &lt;em&gt;custom&lt;/em&gt; variable for a value that does not change, such as a number or a string.&lt;/p&gt;
&lt;p&gt;For example, if you have server names or region names that never change, then you might want to create them as custom variables rather than query variables. Because they do not change, you might use them in &lt;a href=&#34;#chained-variables&#34;&gt;chained variables&lt;/a&gt; rather than other query variables. That would reduce the number of queries Grafana must send when chained variables are updated.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Custom options&lt;/strong&gt; section of the page, select one of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CSV&lt;/strong&gt; - Enter a flat list of values for the variable in a comma-separated list. You can include numbers, strings, or key/value pairs separated by a space and a colon. For example, &lt;code&gt;key1 : value1,key2 : value2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JSON&lt;/strong&gt; - Provide a JSON array of objects where each object can have any number of properties that can be referenced. For more information refer, to &lt;a href=&#34;#configure-multi-property-variables&#34;&gt;Configure multi-property variables&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Configure the settings in the &lt;a href=&#34;#configure-variable-selection-options&#34;&gt;Selection Options&lt;/a&gt; section:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Multi-value&lt;/strong&gt; - Enables multiple values to be selected at the same time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Allow custom values&lt;/strong&gt; - Enables users to add custom values to the list. Only applies to CSV custom values.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include All option&lt;/strong&gt; - Enables an option to include all variables.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Preview of values&lt;/strong&gt; section, Grafana displays a list of the current variable values. If you&amp;rsquo;ve entered a JSON array, the preview is a table that includes all the value properties. Review them to ensure they match what you expect.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-a-text-box-variable&#34;&gt;Add a text box variable&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Text box&lt;/em&gt; variables display a free text input field with an optional default value. This is the most flexible variable, because you can enter any value. Use this type of variable if you have metrics with high cardinality or if you want to update multiple panels in a dashboard at the same time.&lt;/p&gt;
&lt;p&gt;For more information about cardinality, refer to &lt;a href=&#34;/blog/2022/02/15/what-are-cardinality-spikes-and-why-do-they-matter/&#34;&gt;What are cardinality spikes and why do they matter?&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Under the &lt;strong&gt;Text options&lt;/strong&gt; section of the page, in the &lt;strong&gt;Default value&lt;/strong&gt; field, enter the default value for the variable.&lt;/p&gt;
&lt;p&gt;If you do not enter anything in this field, then Grafana displays an empty text box for users to type text into.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-a-constant-variable&#34;&gt;Add a constant variable&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Constant&lt;/em&gt; variables enable you to define a hidden constant. This is useful for metric path prefixes for dashboards you want to share. When you export a dashboard, constant variables are converted to import options.&lt;/p&gt;
&lt;p&gt;Constant variables are &lt;em&gt;not&lt;/em&gt; flexible. Each constant variable only holds one value, and it cannot be updated unless you update the variable settings.&lt;/p&gt;
&lt;p&gt;Constant variables are useful when you have complex values that you need to include in queries but don&amp;rsquo;t want to retype in every query. For example, if you had a server path called &lt;code&gt;i-0b6a61efe2ab843gg&lt;/code&gt;, then you could replace it with a variable called &lt;code&gt;$path_gg&lt;/code&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Constant options&lt;/strong&gt; section of the page, in the &lt;strong&gt;Value&lt;/strong&gt; field, enter the variable value.&lt;/p&gt;
&lt;p&gt;You can enter letters, numbers, and symbols. You can even use wildcards if you use 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/variable-syntax/#raw&#34;&gt;raw format&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-a-data-source-variable&#34;&gt;Add a data source variable&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Data source&lt;/em&gt; variables enable you to quickly change the data source for an entire dashboard. They are useful if you have multiple instances of a data source, perhaps in different environments.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Data source options&lt;/strong&gt; section of the page, in the &lt;strong&gt;Type&lt;/strong&gt; drop-down list, select the target data source for the variable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) In &lt;strong&gt;Instance name filter&lt;/strong&gt;, enter a regular expression filter for which data source instances to choose from in the variable value drop-down list.&lt;/p&gt;
&lt;p&gt;Leave this field empty to display all instances.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Configure the settings in the &lt;a href=&#34;#configure-variable-selection-options&#34;&gt;Selection Options&lt;/a&gt; section:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Multi-value&lt;/strong&gt; - Enables multiple values to be selected at the same time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include All option&lt;/strong&gt; - Enables an option to include all variables.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Preview of values&lt;/strong&gt; section, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-an-interval-variable&#34;&gt;Add an interval variable&lt;/h2&gt;
&lt;p&gt;Use an &lt;em&gt;interval&lt;/em&gt; variable to represents time spans such as &lt;code&gt;1m&lt;/code&gt;,&lt;code&gt;1h&lt;/code&gt;, &lt;code&gt;1d&lt;/code&gt;. You can think of them as a dashboard-wide &amp;ldquo;group by time&amp;rdquo; command. Interval variables change how the data is grouped in the visualization. You can also use the Auto Option to return a set number of data points per time span.&lt;/p&gt;
&lt;p&gt;You can use an interval variable as a parameter to group by time (for InfluxDB), date histogram interval (for Elasticsearch), or as a summarize function parameter (for Graphite).&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Interval options&lt;/strong&gt; section, in the &lt;strong&gt;Values&lt;/strong&gt; field, enter the time range intervals that you want to appear in the variable drop-down list.&lt;/p&gt;
&lt;p&gt;The following time units are supported: &lt;code&gt;s (seconds)&lt;/code&gt;, &lt;code&gt;m (minutes)&lt;/code&gt;, &lt;code&gt;h (hours)&lt;/code&gt;, &lt;code&gt;d (days)&lt;/code&gt;, &lt;code&gt;w (weeks)&lt;/code&gt;, &lt;code&gt;M (months)&lt;/code&gt;, and &lt;code&gt;y (years)&lt;/code&gt;. You can also accept or edit the default values: &lt;code&gt;1m,10m,30m,1h,6h,12h,1d,7d,14d,30d&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Select on the &lt;strong&gt;Auto option&lt;/strong&gt; checkbox if you want to add the &lt;code&gt;auto&lt;/code&gt; option to the list.&lt;/p&gt;
&lt;p&gt;This option allows you to specify how many times the current time range should be divided to calculate the current &lt;code&gt;auto&lt;/code&gt; time span. If you turn it on, then two more options appear:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Step count&lt;/strong&gt; - Select the number of times the current time range is divided to calculate the value, similar to the &lt;strong&gt;Max data points&lt;/strong&gt; query option. For example, if the current visible time range is 30 minutes, then the &lt;code&gt;auto&lt;/code&gt; interval groups the data into 30 one-minute increments. The default value is 30 steps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Min interval&lt;/strong&gt; - The minimum threshold below which the step count intervals does not divide the time. To continue the 30 minute example, if the minimum interval is set to 2m, then Grafana would group the data into 15 two-minute increments.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Preview of values&lt;/strong&gt; section, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;interval-variable-examples&#34;&gt;Interval variable examples&lt;/h3&gt;
&lt;p&gt;The following example shows a template variable &lt;code&gt;myinterval&lt;/code&gt; in a Graphite function:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;summarize($myinterval, sum, false)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following example shows a more complex Graphite example, from the &lt;a href=&#34;https://play.grafana.org/d/000000056/graphite-templated-nested?editPanel=2&amp;amp;orgId=1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Graphite Template Nested Requests panel&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;groupByNode(summarize(movingAverage(apps.$app.$server.counters.requests.count, 5), &amp;#39;$interval&amp;#39;, &amp;#39;sum&amp;#39;, false), 2, &amp;#39;sum&amp;#39;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- vale Grafana.WordList = NO --&gt;
&lt;!-- vale Grafana.Spelling = NO --&gt;
&lt;h2 id=&#34;add-ad-hoc-filters&#34;&gt;Add ad hoc filters&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Ad hoc filters&lt;/em&gt; are one of the most complex and flexible variable options available.
Instead of creating a variable for each dimension by which you want to filter, ad hoc filters automatically create variables (key/value pairs) for all the dimensions returned by your data source query.
This allows you to apply filters dashboard-wide.&lt;/p&gt;
&lt;p&gt;Ad hoc filters let you add label/value filters that are automatically added to all metric queries that use the specified data source.
Unlike other variables, you don&amp;rsquo;t use ad hoc filters in queries.
Instead, you use ad hoc filters to write filters for existing queries.&lt;/p&gt;
&lt;p&gt;The following data sources support ad hoc filters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dashboard - Use this special data source to &lt;a href=&#34;#filter-any-data-using-the-dashboard-data-source&#34;&gt;apply ad hoc filters to data from unsupported data sources&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Prometheus&lt;/li&gt;
&lt;li&gt;Loki&lt;/li&gt;
&lt;li&gt;InfluxDB&lt;/li&gt;
&lt;li&gt;Elasticsearch&lt;/li&gt;
&lt;li&gt;OpenSearch&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To create an ad hoc filter, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Ad-hoc options&lt;/strong&gt; section of the page, select a target data source in the &lt;strong&gt;Data source&lt;/strong&gt; drop-down list.&lt;/p&gt;
&lt;p&gt;You can also click &lt;strong&gt;Open advanced data source picker&lt;/strong&gt; to see more options, including adding a data source (Admins only).
For more information about data sources, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/#add-a-data-source&#34;&gt;Add a data source&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) To provide the filter dimensions as comma-separated values (CSV), toggle the &lt;strong&gt;Use static key dimensions&lt;/strong&gt; switch on, and then enter the values in the space provided.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter an optional description of your dashboard changes, and then click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you can 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/use-dashboards/#filter-dashboard-data&#34;&gt;filter data on the dashboard&lt;/a&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-tip&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Tip&lt;/p&gt;&lt;p&gt;You can use data links to link back to the dashboard you are currently on. This enables &amp;ldquo;panel-to-panel filtering,&amp;rdquo; where clicking a data point in one panel updates the dashboard variables and filters the rest of the dashboard.&lt;/p&gt;
&lt;p&gt;To preserve the context of the current dashboard:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Time range:&lt;/strong&gt; You must explicitly include the current time range in the link.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variables:&lt;/strong&gt; You must enable &lt;strong&gt;Include all variables&lt;/strong&gt; to preserve existing selections.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ordering:&lt;/strong&gt; Ensure that &lt;strong&gt;Include all variables&lt;/strong&gt; is placed before the specific variable you are defining in the link.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ad hoc filters on the current dashboard are automatically preserved.&lt;/p&gt;
&lt;p&gt;Learn more in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/visualizations/panels-visualizations/configure-data-links/&#34;&gt;Configure data links and actions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v12.4/visualizations/dashboards/build-dashboards/create-dashboard-url-variables/#ad-hoc-filters&#34;&gt;Create dashboard URL variables – Ad hoc filters&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;filter-any-data-using-the-dashboard-data-source&#34;&gt;Filter any data using the Dashboard data source&lt;/h3&gt;
&lt;p&gt;In cases where a data source doesn&amp;rsquo;t support the use of ad hoc filters, you can use the Dashboard data source to reference that data, and then filter it in a new panel.
This allows you to bypass the limitations of the data source in the source panel.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 750px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png&#34;data-srcset=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=320 320w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=550 550w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=750 750w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=900 900w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=1040 1040w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=1240 1240w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;The query section of a panel with the Dashboard data source configured&#34;width=&#34;2256&#34;height=&#34;644&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-dashboard-ds-v12.2.png&#34;
            alt=&#34;The query section of a panel with the Dashboard data source configured&#34;width=&#34;2256&#34;height=&#34;644&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;To use ad hoc filters on data from an unsupported data source, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the dashboard with the panel with the data you want to filter.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Edit&lt;/strong&gt; in top-right corner of the dashboard.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;At the top of the dashboard, click &lt;strong&gt;Add&lt;/strong&gt; and select &lt;strong&gt;Visualization&lt;/strong&gt; in the drop-down list.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Queries&lt;/strong&gt; tab of the edit panel view, enter &lt;code&gt;Dashboard&lt;/code&gt; in the &lt;strong&gt;Data source&lt;/strong&gt; field and select &lt;strong&gt;&amp;ndash; Dashboard &amp;ndash;&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the query configuration section, make the following selections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Source panel&lt;/strong&gt; - Choose the panel with the source data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data&lt;/strong&gt; - Select &lt;strong&gt;All Data&lt;/strong&gt; to use the data of the panel, and not just the annotations. This is the default selection.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AdHoc Filters&lt;/strong&gt; - Toggle on the switch to make the data from the referenced panel filterable.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you&amp;rsquo;re referencing multiple panels in a dashboard with the Dashboard data source, you can only use one of those source panels at a time for ad hoc filtering.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure any other needed options for the panel.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you can filter the data from the source panel by way of the Dashboard data source.
Add as many panels as you need.&lt;/p&gt;
&lt;h3 id=&#34;dashboard-drilldown-with-ad-hoc-filters&#34;&gt;Dashboard drilldown with ad hoc filters&lt;/h3&gt;
&lt;p&gt;In table and bar chart visualizations, you can apply ad hoc filters directly from the visualization.
To quickly apply ad hoc filter variables, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To display the filter icons, hover your cursor over the table cell with the value for which you want to filter. In this example, the cell value is &lt;code&gt;ConfigMap Updated&lt;/code&gt;, which is in the &lt;code&gt;alertname&lt;/code&gt; column:&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
       style=&#34;max-width: 550px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link&#34;
           href=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png&#34;
           itemprop=&#34;contentUrl&#34;
         &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
             class=&#34;lazyload &#34;
             data-src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png&#34;data-srcset=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=320 320w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=550 550w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=750 750w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=900 900w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=1040 1040w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=1240 1240w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Table and bar chart with ad hoc filter icon displayed on a table cell&#34;width=&#34;1616&#34;height=&#34;1402&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-v12.2.png&#34;
               alt=&#34;Table and bar chart with ad hoc filter icon displayed on a table cell&#34;width=&#34;1616&#34;height=&#34;1402&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;In bar chart visualizations, hover and click the bar to display the filter button:&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
       style=&#34;max-width: 300px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link&#34;
           href=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png&#34;
           itemprop=&#34;contentUrl&#34;
         &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
             class=&#34;lazyload &#34;
             data-src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png&#34;data-srcset=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=320 320w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=550 550w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=750 750w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=900 900w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=1040 1040w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=1240 1240w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;The ad hoc filter button in a bar chart tooltip&#34;width=&#34;718&#34;height=&#34;402&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-icon-bar-v12.2.png&#34;
               alt=&#34;The ad hoc filter button in a bar chart tooltip&#34;width=&#34;718&#34;height=&#34;402&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the add filter icon.&lt;/p&gt;
&lt;p&gt;The variable pair &lt;code&gt;alertname = ConfigMap Updated&lt;/code&gt; is added to the ad hoc filter and all panels using the same data source that include that variable value are filtered by that value:&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
       style=&#34;max-width: 550px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link&#34;
           href=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png&#34;
           itemprop=&#34;contentUrl&#34;
         &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
             class=&#34;lazyload &#34;
             data-src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png&#34;data-srcset=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=320 320w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=550 550w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=750 750w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=900 900w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=1040 1040w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=1240 1240w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Table and bar chart, filtered&#34;width=&#34;1632&#34;height=&#34;1414&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-applied-v12.2.png&#34;
               alt=&#34;Table and bar chart, filtered&#34;width=&#34;1632&#34;height=&#34;1414&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If one of the panels in the dashboard using that data source doesn&amp;rsquo;t include that variable value, the panel won&amp;rsquo;t return any data. In this example, the variable pair &lt;code&gt;_name_ = ALERTS&lt;/code&gt; has been added to the ad hoc filter so the bar chart doesn&amp;rsquo;t return any results:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 650px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png&#34;data-srcset=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=320 320w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=550 550w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=750 750w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=900 900w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=1040 1040w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=1240 1240w, /media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Table, filtered and bar chart returning no results&#34;width=&#34;1612&#34;height=&#34;956&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/panels-visualizations/screenshot-adhoc-filter-no-data-v12.2.png&#34;
            alt=&#34;Table, filtered and bar chart returning no results&#34;width=&#34;1612&#34;height=&#34;956&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;In cases where the data source you&amp;rsquo;re using doesn&amp;rsquo;t support ad hoc filtering, consider using the special Dashboard data source.
For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/add-template-variables/#filter-any-data-using-the-dashboard-data-source&#34;&gt;Filter any data using the Dashboard data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;add-a-switch-variable&#34;&gt;Add a switch variable&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Switch&lt;/em&gt; variables display a switch with two configurable values representing enabled and disabled states. This variable type is useful when you need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Toggle between different query conditions&lt;/li&gt;
&lt;li&gt;Enable or disable specific filters&lt;/li&gt;
&lt;li&gt;Switch between different visualization modes&lt;/li&gt;
&lt;li&gt;Control boolean parameters in your data sources&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#enter-general-options&#34;&gt;Enter general options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under the &lt;strong&gt;Switch options&lt;/strong&gt; section of the page, configure the switch values:&lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;Value pair type&lt;/strong&gt; drop-down list, select one of the following predefined options or choose &lt;strong&gt;Custom&lt;/strong&gt; to define your own values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;True / False&lt;/strong&gt; - Uses boolean values &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;1 / 0&lt;/strong&gt; - Uses numeric values &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Yes / No&lt;/strong&gt; - Uses string values &lt;code&gt;yes&lt;/code&gt; and &lt;code&gt;no&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom&lt;/strong&gt; - Allows you to define custom values for both enabled and disabled states&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you selected &lt;strong&gt;Custom&lt;/strong&gt; in the previous step, configure the custom values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Enabled value&lt;/strong&gt; - Enter the value that represents the enabled state (for example, &amp;ldquo;on&amp;rdquo;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Disabled value&lt;/strong&gt; - Enter the value that represents the disabled state (for example, &amp;ldquo;off&amp;rdquo;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save dashboard&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Back to dashboard&lt;/strong&gt; and &lt;strong&gt;Exit edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;switch-variable-examples&#34;&gt;Switch variable examples&lt;/h3&gt;
&lt;p&gt;The following example shows a switch variable &lt;code&gt;$debug_mode&lt;/code&gt; used in a Prometheus query to conditionally include debug labels:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;up{job=&amp;#34;my-service&amp;#34;} and ($debug_mode == &amp;#34;true&amp;#34; or on() vector(0))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following example shows a switch variable &lt;code&gt;$show_errors&lt;/code&gt; used to filter log entries:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{job=&amp;#34;application&amp;#34;} |= ($show_errors == &amp;#34;1&amp;#34; ? &amp;#34;ERROR&amp;#34; : &amp;#34;&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also use switch variables in panel titles and other dashboard elements:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{{#if debug_mode}}Debug Mode: {{/if}}Application Metrics&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- vale Grafana.Spelling = YES --&gt;
&lt;!-- vale Grafana.WordList = YES --&gt;
&lt;h2 id=&#34;configure-variable-selection-options&#34;&gt;Configure variable selection options&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Selection Options&lt;/strong&gt; are a feature you can use to manage variable option selections. All selection options are optional, and they are off by default.&lt;/p&gt;
&lt;h3 id=&#34;multi-value-variables&#34;&gt;Multi-value variables&lt;/h3&gt;
&lt;p&gt;Interpolating a variable with multiple values selected is tricky as it is not straight forward how to format the multiple values into a string that is valid in the given context where the variable is used. Grafana tries to solve this by allowing each data source plugin to inform the templating interpolation engine what format to use for multiple values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &lt;strong&gt;Custom all value&lt;/strong&gt; option on the variable must be blank for Grafana to format all values into a single string. If it is left blank, then Grafana concatenates (adds together) all the values in the query. Something like &lt;code&gt;value1,value2,value3&lt;/code&gt;. If a custom &lt;code&gt;all&lt;/code&gt; value is used, then instead the value is something like &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;all&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h4 id=&#34;multi-value-variables-with-a-graphite-data-source&#34;&gt;Multi-value variables with a Graphite data source&lt;/h4&gt;
&lt;p&gt;Graphite uses glob expressions. A variable with multiple values would, in this case, be interpolated as &lt;code&gt;{host1,host2,host3}&lt;/code&gt; if the current variable value was &lt;em&gt;host1&lt;/em&gt;, &lt;em&gt;host2&lt;/em&gt;, and &lt;em&gt;host3&lt;/em&gt;.&lt;/p&gt;
&lt;h4 id=&#34;multi-value-variables-with-a-prometheus-or-influxdb-data-source&#34;&gt;Multi-value variables with a Prometheus or InfluxDB data source&lt;/h4&gt;
&lt;p&gt;InfluxDB and Prometheus use regular expressions, so the same variable would be interpolated as &lt;code&gt;(host1|host2|host3)&lt;/code&gt;. Every value would also be regular expression escaped. If not, a value with a regular expression control character would break the regular expression.&lt;/p&gt;
&lt;h4 id=&#34;multi-value-variables-with-an-elastic-data-source&#34;&gt;Multi-value variables with an Elastic data source&lt;/h4&gt;
&lt;p&gt;Elasticsearch uses Lucene query syntax, so the same variable would be formatted as &lt;code&gt;(&amp;quot;host1&amp;quot; OR &amp;quot;host2&amp;quot; OR &amp;quot;host3&amp;quot;)&lt;/code&gt;. In this case, every value must be escaped so that the value only contains Lucene control words and quotation marks.&lt;/p&gt;
&lt;h4 id=&#34;variable-indexing&#34;&gt;Variable indexing&lt;/h4&gt;
&lt;p&gt;If you have a multi-value variable that&amp;rsquo;s formatted as an array, you can use array positions to reference the values rather than the actual values.
You can use this functionality in dashboard panels to filter data, and when you do so, the array is maintained.&lt;/p&gt;
&lt;p&gt;To reference variable values this way, use the following syntax:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;${query0.0}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The preceding syntax references the first, or &lt;code&gt;0&lt;/code&gt;, position in the array.&lt;/p&gt;
&lt;p&gt;In the following example, there&amp;rsquo;s an array of three values, &lt;code&gt;1t&lt;/code&gt;, &lt;code&gt;2t&lt;/code&gt;, and &lt;code&gt;3t&lt;/code&gt;, and rather than referencing those values, the panel query references the second value in the array using the syntax &lt;code&gt;${query0.1}&lt;/code&gt;:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 750px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png&#34;data-srcset=&#34;/media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=320 320w, /media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=550 550w, /media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=750 750w, /media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=900 900w, /media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=1040 1040w, /media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=1240 1240w, /media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Panel query using variable indexing to reference a value&#34;width=&#34;2362&#34;height=&#34;1258&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/dashboards/screenshot-indexed-variables-v12.1.png&#34;
            alt=&#34;Panel query using variable indexing to reference a value&#34;width=&#34;2362&#34;height=&#34;1258&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h4 id=&#34;troubleshoot-multi-value-variables&#34;&gt;Troubleshoot multi-value variables&lt;/h4&gt;
&lt;p&gt;Automatic escaping and formatting can cause problems and it can be tricky to grasp the logic behind it. Especially for InfluxDB and Prometheus where the use of regular expression syntax requires that the variable is used in regular expression operator context.&lt;/p&gt;
&lt;p&gt;If you do not want Grafana to do this automatic regular expression escaping and formatting, then you must do one of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Turn off the &lt;strong&gt;Multi-value&lt;/strong&gt; or &lt;strong&gt;Include All option&lt;/strong&gt; options.&lt;/li&gt;
&lt;li&gt;Use the 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/variable-syntax/#raw&#34;&gt;raw variable format&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;include-all-option&#34;&gt;Include All option&lt;/h3&gt;
&lt;p&gt;Grafana adds an &lt;code&gt;All&lt;/code&gt; option to the variable dropdown list. If a user selects this option, then all variable options are selected.&lt;/p&gt;
&lt;h3 id=&#34;custom-all-value&#34;&gt;Custom all value&lt;/h3&gt;
&lt;p&gt;This option is only visible if the &lt;strong&gt;Include All option&lt;/strong&gt; is selected.&lt;/p&gt;
&lt;p&gt;Enter regular expressions, globs, or Lucene syntax in the &lt;strong&gt;Custom all value&lt;/strong&gt; field to define the value of the &lt;code&gt;All&lt;/code&gt; option.&lt;/p&gt;
&lt;p&gt;By default the &lt;code&gt;All&lt;/code&gt; value includes all options in combined expression. This can become very long and can have performance problems. Sometimes it can be better to specify a custom all value, like a wildcard regular expression.&lt;/p&gt;
&lt;p&gt;In order to have custom regular expression, globs, or Lucene syntax in the &lt;strong&gt;Custom all value&lt;/strong&gt; option, it is never escaped so you have to think about what is a valid value for your data source.&lt;/p&gt;
&lt;h2 id=&#34;configure-multi-property-variables&#34;&gt;Configure multi-property variables&lt;/h2&gt;
&lt;p&gt;If you have a multi-source dashboard that uses multiple variables for the same logical concept—for example, an environment identified as &lt;code&gt;dev&lt;/code&gt; vs &lt;code&gt;development&lt;/code&gt;—, you can set up a multi-property variable to let you reference all those values. Instead of creating and keeping multiple variables for the same logical concept in sync, you can map all of those identifiers to one variable and then reference any property you need in panels and queries.&lt;/p&gt;
&lt;p&gt;To do so, configure a JSON array in which each object can have any number of properties.
Then, you can reference any of the properties in as you use those variables.&lt;/p&gt;
&lt;p&gt;This applies to the following variable types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Custom&lt;/li&gt;
&lt;li&gt;Query
&lt;ul&gt;
&lt;li&gt;Infinity&lt;/li&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- add links to data source docs --&gt;
&lt;h3 id=&#34;multi-property-custom-variables&#34;&gt;Multi-property custom variables&lt;/h3&gt;
&lt;p&gt;To create a custom variable with multiple properties, define a JSON array, like this:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;[
  { &amp;#34;value&amp;#34;: &amp;#34;1&amp;#34;, &amp;#34;text&amp;#34;: &amp;#34;Development&amp;#34;, &amp;#34;aws&amp;#34;: &amp;#34;dev&amp;#34;, &amp;#34;azure&amp;#34;: &amp;#34;development&amp;#34;, &amp;#34;google&amp;#34;: &amp;#34;googledev&amp;#34; },
  { &amp;#34;value&amp;#34;: &amp;#34;2&amp;#34;, &amp;#34;text&amp;#34;: &amp;#34;Staging&amp;#34;, &amp;#34;aws&amp;#34;: &amp;#34;stag&amp;#34;, &amp;#34;azure&amp;#34;: &amp;#34;staging&amp;#34;, &amp;#34;google&amp;#34;: &amp;#34;googlestag&amp;#34; },
  { &amp;#34;value&amp;#34;: &amp;#34;3&amp;#34;, &amp;#34;text&amp;#34;: &amp;#34;Production&amp;#34;, &amp;#34;aws&amp;#34;: &amp;#34;prod&amp;#34;, &amp;#34;azure&amp;#34;: &amp;#34;production&amp;#34;, &amp;#34;google&amp;#34;: &amp;#34;googleprod&amp;#34; }
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is how those values are displayed in a preview:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 600px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png&#34;data-srcset=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=320 320w, /media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=550 550w, /media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=750 750w, /media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=900 900w, /media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=1040 1040w, /media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=1240 1240w, /media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Custom variable configuration and preview of values&#34;width=&#34;1500&#34;height=&#34;1054&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-preview-vals-v12.4.png&#34;
            alt=&#34;Custom variable configuration and preview of values&#34;width=&#34;1500&#34;height=&#34;1054&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Then you can use &lt;code&gt;${varName.someProperty}&lt;/code&gt; syntax to reference any property in your dashboard panels or metrics:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: ZgotmplZ;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png&#34;data-srcset=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=320 320w, /media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=550 550w, /media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=750 750w, /media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=900 900w, /media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=1040 1040w, /media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=1240 1240w, /media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Multi-property variable used in a text panel&#34;width=&#34;2196&#34;height=&#34;1466&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-used-12.4.png&#34;
            alt=&#34;Multi-property variable used in a text panel&#34;width=&#34;2196&#34;height=&#34;1466&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;You can even deeply nest properties and still access them using familiar variable syntax. In the following example, each user has an address property with all the elements of an address nested within it:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 650px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png&#34;data-srcset=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=320 320w, /media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=550 550w, /media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=750 750w, /media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=900 900w, /media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=1040 1040w, /media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=1240 1240w, /media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Nested variable configuration&#34;width=&#34;1498&#34;height=&#34;1214&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/grafana/dashboards/screenshot-multipropvar-nested-v12.4.png&#34;
            alt=&#34;Nested variable configuration&#34;width=&#34;1498&#34;height=&#34;1214&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;multi-property-query-variables&#34;&gt;Multi-property query variables&lt;/h3&gt;
&lt;p&gt;Because query configuration is different for each data source, there&amp;rsquo;s no one way to set up a JSON array to create a multi-property query variable.
For PostgreSQL, refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/postgres/template-variables/&#34;&gt;PostgreSQL template variables&lt;/a&gt;.
For other data sources, refer to the relevant 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/&#34;&gt;Data sources documentation&lt;/a&gt; for preinstalled data source plugins.
For configuration information on all other data source plugins, refer to the &lt;a href=&#34;/docs/plugins/&#34;&gt;Plugins documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;global-variables&#34;&gt;Global variables&lt;/h2&gt;
&lt;p&gt;Grafana has global built-in variables that can be used in expressions in the query editor. This topic lists them in alphabetical order and defines them. These variables are useful in queries, dashboard links, panel links, and data links.&lt;/p&gt;
&lt;h3 id=&#34;__dashboard&#34;&gt;&lt;code&gt;$__dashboard&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;This variable is the name of the current dashboard.&lt;/p&gt;
&lt;h3 id=&#34;__from-and-__to&#34;&gt;&lt;code&gt;$__from&lt;/code&gt; and &lt;code&gt;$__to&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Grafana has two built-in time range variables: &lt;code&gt;$__from&lt;/code&gt; and &lt;code&gt;$__to&lt;/code&gt;. They are currently always interpolated as epoch milliseconds by default, but you can control date formatting.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Syntax&lt;/th&gt;
              &lt;th&gt;Example result&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;${__from}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;1594671549254&lt;/td&gt;
              &lt;td&gt;Unix millisecond epoch&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;${__from:date}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;2020-07-13T20:19:09.254Z&lt;/td&gt;
              &lt;td&gt;No arguments, defaults to ISO 8601/RFC 3339&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;${__from:date:iso}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;2020-07-13T20:19:09.254Z&lt;/td&gt;
              &lt;td&gt;ISO 8601/RFC 3339&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;${__from:date:seconds}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;1594671549&lt;/td&gt;
              &lt;td&gt;Unix seconds epoch&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;${__from:date:YYYY-MM}&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;2020-07&lt;/td&gt;
              &lt;td&gt;Any custom &lt;a href=&#34;https://momentjs.com/docs/#/displaying/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;date format&lt;/a&gt; that does not include the &lt;code&gt;:&lt;/code&gt; character. Uses browser time. Use &lt;code&gt;:date&lt;/code&gt; or &lt;code&gt;:date:iso&lt;/code&gt; for UTC&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The syntax above also works with &lt;code&gt;${__to}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can use this variable in URLs, as well. For example, you can send a user to a dashboard that shows a time range from six hours ago until now: &lt;a href=&#34;https://play.grafana.org/d/000000012/grafana-play-home?viewPanel=2&amp;amp;orgId=1?from=now-6h&amp;amp;to=now&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://play.grafana.org/d/000000012/grafana-play-home?viewPanel=2&amp;orgId=1?from=now-6h&amp;to=now&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;__interval&#34;&gt;&lt;code&gt;$__interval&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;You can use the &lt;code&gt;$__interval&lt;/code&gt; variable as a parameter to group by time (for InfluxDB, MySQL, Postgres, MSSQL), Date histogram interval (for Elasticsearch), or as a &lt;em&gt;summarize&lt;/em&gt; function parameter (for Graphite).&lt;/p&gt;
&lt;p&gt;Grafana automatically calculates an interval that can be used to group by time in queries. When there are more data points than can be shown on a graph, then queries can be made more efficient by grouping by a larger interval. It is more efficient to group by 1 day than by 10s when looking at 3 months of data. The graph looks the same and the query is faster. The &lt;code&gt;$__interval&lt;/code&gt; is calculated using the time range and the width of the graph (the number of pixels).&lt;/p&gt;
&lt;p&gt;Approximate Calculation: &lt;code&gt;(to - from) / resolution&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For example, when the time range is 1 hour and the graph is full screen, then the interval might be calculated to &lt;code&gt;2m&lt;/code&gt; - points are grouped in 2 minute intervals. If the time range is 6 months and the graph is full screen, then the interval might be &lt;code&gt;1d&lt;/code&gt; (1 day) - points are grouped by day.&lt;/p&gt;
&lt;p&gt;In the InfluxDB data source, the legacy variable &lt;code&gt;$interval&lt;/code&gt; is the same variable. &lt;code&gt;$__interval&lt;/code&gt; should be used instead.&lt;/p&gt;
&lt;p&gt;The InfluxDB and Elasticsearch data sources have &lt;code&gt;Group by time interval&lt;/code&gt; fields that are used to hard code the interval or to set the minimum limit for the &lt;code&gt;$__interval&lt;/code&gt; variable (by using the &lt;code&gt;&amp;gt;&lt;/code&gt; syntax -&amp;gt; &lt;code&gt;&amp;gt;10m&lt;/code&gt;).&lt;/p&gt;
&lt;h3 id=&#34;__interval_ms&#34;&gt;&lt;code&gt;$__interval_ms&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;This variable is the &lt;code&gt;$__interval&lt;/code&gt; variable in milliseconds, not a time interval formatted string. For example, if the &lt;code&gt;$__interval&lt;/code&gt; is &lt;code&gt;20m&lt;/code&gt; then the &lt;code&gt;$__interval_ms&lt;/code&gt; is &lt;code&gt;1200000&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;__name&#34;&gt;&lt;code&gt;$__name&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;This variable is only available in the &lt;strong&gt;Singlestat&lt;/strong&gt; panel and can be used in the prefix or suffix fields on the Options tab. The variable is replaced with the series name or alias.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &lt;strong&gt;Singlestat&lt;/strong&gt; panel is no longer available from Grafana 8.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;__org&#34;&gt;&lt;code&gt;$__org&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;This variable is the ID of the current organization.
&lt;code&gt;${__org.name}&lt;/code&gt; is the name of the current organization.&lt;/p&gt;
&lt;h3 id=&#34;__user&#34;&gt;&lt;code&gt;$__user&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;${__user.id}&lt;/code&gt; is the ID of the current user.
&lt;code&gt;${__user.login}&lt;/code&gt; is the login handle of the current user.
&lt;code&gt;${__user.email}&lt;/code&gt; is the email for the current user.&lt;/p&gt;
&lt;h3 id=&#34;__range&#34;&gt;&lt;code&gt;$__range&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Currently only supported for Prometheus and Loki data sources. This variable represents the range for the current dashboard. It is calculated by &lt;code&gt;to - from&lt;/code&gt;. It has a millisecond and a second representation called &lt;code&gt;$__range_ms&lt;/code&gt; and &lt;code&gt;$__range_s&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;__rate_interval&#34;&gt;&lt;code&gt;$__rate_interval&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Currently only supported for Prometheus data sources. The &lt;code&gt;$__rate_interval&lt;/code&gt; variable is meant to be used in the rate function. Refer to 
    &lt;a href=&#34;/docs/grafana/v12.4/datasources/prometheus/template-variables/#use-**rate_interval&#34;&gt;Prometheus query variables&lt;/a&gt; for details.&lt;/p&gt;
&lt;h3 id=&#34;__rate_interval_ms&#34;&gt;&lt;code&gt;$__rate_interval_ms&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;This variable is the &lt;code&gt;$__rate_interval&lt;/code&gt; variable in milliseconds, not a time-interval-formatted string. For example, if the &lt;code&gt;$__rate_interval&lt;/code&gt; is &lt;code&gt;20m&lt;/code&gt; then the &lt;code&gt;$__rate_interval_ms&lt;/code&gt; is &lt;code&gt;1200000&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;timefilter-or-__timefilter&#34;&gt;&lt;code&gt;$timeFilter&lt;/code&gt; or &lt;code&gt;$__timeFilter&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;$timeFilter&lt;/code&gt; variable returns the currently selected time range as an expression. For example, the time range interval &lt;code&gt;Last 7 days&lt;/code&gt; expression is &lt;code&gt;time &amp;gt; now() - 7d&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is used in several places, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The WHERE clause for the InfluxDB data source. Grafana adds it automatically to InfluxDB queries when in Query Editor mode. You can add it manually in Text Editor mode: &lt;code&gt;WHERE $timeFilter&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Log Analytics queries in the Azure Monitor data source.&lt;/li&gt;
&lt;li&gt;SQL queries in MySQL, Postgres, and MSSQL.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;$__timeFilter&lt;/code&gt; variable is used in the MySQL data source.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;__timezone&#34;&gt;&lt;code&gt;$__timezone&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;$__timezone&lt;/code&gt; variable returns the currently selected time zone, either &lt;code&gt;utc&lt;/code&gt; or an entry of the IANA time zone database (for example, &lt;code&gt;America/New_York&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;If the currently selected time zone is &lt;em&gt;Browser Time&lt;/em&gt;, Grafana tries to determine your browser time zone.&lt;/p&gt;
&lt;h2 id=&#34;chained-variables&#34;&gt;Chained variables&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Chained variables&lt;/em&gt;, also called &lt;em&gt;linked variables&lt;/em&gt; or &lt;em&gt;nested variables&lt;/em&gt;, are query variables with one or more other variables in their variable query. This section explains how chained variables work and provides links to example dashboards that use chained variables.&lt;/p&gt;
&lt;p&gt;Chained variable queries are different for every data source, but the premise is the same for all. You can use chained variable queries in any data source that allows them.&lt;/p&gt;
&lt;p&gt;Extremely complex linked templated dashboards are possible, 5 or 10 levels deep. Technically, there is no limit to how deep or complex you can go, but the more links you have, the greater the query load.&lt;/p&gt;
&lt;h3 id=&#34;grafana-play-dashboard-examples&#34;&gt;Grafana Play dashboard examples&lt;/h3&gt;
&lt;p&gt;The following Grafana Play dashboards contain fairly simple chained variables, only two layers deep. To view the variables and their settings, click &lt;strong&gt;Edit&lt;/strong&gt;
and then &lt;strong&gt;Settings&lt;/strong&gt;; then go to the &lt;strong&gt;Variables&lt;/strong&gt; tab. Both examples are expanded in the following section.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://play.grafana.org/d/000000056/graphite-templated-nested?orgId=1&amp;amp;var-app=country&amp;amp;var-server=All&amp;amp;var-interval=1h&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Graphite Templated Nested&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://play.grafana.org/d/e7bad3ef-db0c-4bbd-8245-b85c0b2ca2b9/influx-2-73a-hourly-electric-grid-monitor-for-us?orgId=1&amp;amp;refresh=1m&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxDB Templated&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;examples-explained&#34;&gt;Examples explained&lt;/h3&gt;
&lt;p&gt;Variables are useful to reuse dashboards and dynamically change what is shown in dashboards. Chained variables are especially useful to filter what you see.&lt;/p&gt;
&lt;p&gt;Create parent/child relationship in a variable, sort of a tree structure where you can select different levels of filters.&lt;/p&gt;
&lt;p&gt;The following sections explain the linked examples in the dashboards above in depth and builds on them. While the examples are data source-specific, the concepts can be applied broadly.&lt;/p&gt;
&lt;h4 id=&#34;graphite-example&#34;&gt;Graphite example&lt;/h4&gt;
&lt;p&gt;In this example, there are several applications. Each application has a different subset of servers. It is based on the &lt;a href=&#34;https://play.grafana.org/d/000000056/graphite-templated-nested?orgId=1&amp;amp;var-app=country&amp;amp;var-server=All&amp;amp;var-interval=1h&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Graphite Templated Nested&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now, you could make separate variables for each metric source, but then you have to know which server goes with which app. A better solution is to use one variable to filter another. In this example, when the user changes the value of the &lt;code&gt;app&lt;/code&gt; variable, it changes the dropdown options returned by the &lt;code&gt;server&lt;/code&gt; variable. Both variables use the &lt;strong&gt;Multi-value&lt;/strong&gt; option and &lt;strong&gt;Include all option&lt;/strong&gt;, enabling users to select some or all options presented at any time.&lt;/p&gt;
&lt;h5 id=&#34;app-variable&#34;&gt;&lt;code&gt;app&lt;/code&gt; variable&lt;/h5&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Find all the applications that exist.&amp;rdquo;&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;apps.*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The values returned are &lt;code&gt;backend&lt;/code&gt;, &lt;code&gt;country&lt;/code&gt;, &lt;code&gt;fakesite&lt;/code&gt;, and &lt;code&gt;All&lt;/code&gt;.&lt;/p&gt;
&lt;h5 id=&#34;server-variable&#34;&gt;&lt;code&gt;server&lt;/code&gt; variable&lt;/h5&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Find all servers for the currently chosen application.&amp;rdquo;&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;apps.$app.*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If the user selects &lt;code&gt;backend&lt;/code&gt;, then the query changes to:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;apps.backend.*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The query returns all servers associated with &lt;code&gt;backend&lt;/code&gt;, including &lt;code&gt;backend_01&lt;/code&gt;, &lt;code&gt;backend_02&lt;/code&gt;, and so on.&lt;/p&gt;
&lt;p&gt;If the user selects &lt;code&gt;fakesite&lt;/code&gt;, then the query changes to:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;apps.fakesite.*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The query returns all servers associated with &lt;code&gt;fakesite&lt;/code&gt;, including &lt;code&gt;web_server_01&lt;/code&gt;, &lt;code&gt;web_server_02&lt;/code&gt;, and so on.&lt;/p&gt;
&lt;h5 id=&#34;more-variables&#34;&gt;More variables&lt;/h5&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;This example is theoretical. The Graphite server used in the example does not contain CPU metrics.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;The dashboard stops at two levels, but you could keep going. For example, if you wanted to get CPU metrics for selected servers, you could copy the &lt;code&gt;server&lt;/code&gt; variable and extend the query so that it reads:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;apps.$app.$server.cpu.*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This query basically says, &amp;ldquo;Find the CPU metrics for the selected server.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Depending on what variable options the user selects, you could get queries like:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;apps.backend.backend_01.cpu.*
apps.{backend.backend_02,backend_03}.cpu.*
apps.fakesite.web_server_01.cpu.*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;influxdb-example&#34;&gt;InfluxDB example&lt;/h4&gt;
&lt;p&gt;In this example, you have several data centers. Each data center has a different subset of hosts. It is based on the &lt;a href=&#34;https://play.grafana.org/d/e7bad3ef-db0c-4bbd-8245-b85c0b2ca2b9/influx-2-73a-hourly-electric-grid-monitor-for-us?orgId=1&amp;amp;refresh=1m&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxDB Templated&lt;/a&gt; dashboard.&lt;/p&gt;
&lt;p&gt;In this example, when the user changes the value of the &lt;code&gt;datacenter&lt;/code&gt; variable, it changes the dropdown options returned by the &lt;code&gt;host&lt;/code&gt; variable. The &lt;code&gt;host&lt;/code&gt; variable uses the &lt;strong&gt;Multi-value&lt;/strong&gt; option and &lt;strong&gt;Include all option&lt;/strong&gt;, allowing users to select some or all options presented at any time. The &lt;code&gt;datacenter&lt;/code&gt; does not use either option, so you can only select one data center at a time.&lt;/p&gt;
&lt;h5 id=&#34;datacenter-variable&#34;&gt;&lt;code&gt;datacenter&lt;/code&gt; variable&lt;/h5&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Find all the data centers that exist.&amp;rdquo;&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;SHOW TAG VALUES WITH KEY = &amp;#34;datacenter&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The values returned are &lt;code&gt;America&lt;/code&gt;, &lt;code&gt;Africa&lt;/code&gt;, &lt;code&gt;Asia&lt;/code&gt;, and &lt;code&gt;Europe&lt;/code&gt;.&lt;/p&gt;
&lt;h5 id=&#34;host-variable&#34;&gt;&lt;code&gt;host&lt;/code&gt; variable&lt;/h5&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Find all hosts for the currently chosen data center.&amp;rdquo;&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;SHOW TAG VALUES WITH KEY = &amp;#34;hostname&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^$datacenter$/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If the user selects &lt;code&gt;America&lt;/code&gt;, then the query changes to:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;SHOW TAG VALUES WITH KEY = &amp;#34;hostname&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^America/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The query returns all servers associated with &lt;code&gt;America&lt;/code&gt;, including &lt;code&gt;server1&lt;/code&gt;, &lt;code&gt;server2&lt;/code&gt;, and so on.&lt;/p&gt;
&lt;p&gt;If the user selects &lt;code&gt;Europe&lt;/code&gt;, then the query changes to:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;SHOW TAG VALUES WITH KEY = &amp;#34;hostname&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^Europe/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The query returns all servers associated with &lt;code&gt;Europe&lt;/code&gt;, including &lt;code&gt;server3&lt;/code&gt;, &lt;code&gt;server4&lt;/code&gt;, and so on.&lt;/p&gt;
&lt;h5 id=&#34;more-variables-1&#34;&gt;More variables&lt;/h5&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;This example is theoretical. The InfluxDB server used in the example does not contain CPU metrics.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;The dashboard stops at two levels, but you could keep going. For example, if you wanted to get CPU metrics for selected hosts, you could copy the &lt;code&gt;host&lt;/code&gt; variable and extend the query so that it reads:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;SHOW TAG VALUES WITH KEY = &amp;#34;cpu&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^$datacenter$/ AND &amp;#34;host&amp;#34; =~ /^$host$/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This query basically says, &amp;ldquo;Find the CPU metrics for the selected host.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Depending on what variable options the user selects, you could get queries like:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;SHOW TAG VALUES WITH KEY = &amp;#34;cpu&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^America/ AND &amp;#34;host&amp;#34; =~ /^server2/
SHOW TAG VALUES WITH KEY = &amp;#34;cpu&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^Africa/ AND &amp;#34;host&amp;#34; =~ /^server/7/
SHOW TAG VALUES WITH KEY = &amp;#34;cpu&amp;#34; WHERE &amp;#34;datacenter&amp;#34; =~ /^Europe/ AND &amp;#34;host&amp;#34; =~ /^server3&amp;#43;server4/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;best-practices-and-tips&#34;&gt;Best practices and tips&lt;/h3&gt;
&lt;p&gt;The following practices make your dashboards and variables easier to use.&lt;/p&gt;
&lt;h4 id=&#34;new-linked-variables-creation&#34;&gt;New linked variables creation&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Chaining variables create parent/child dependencies. You can envision them as a ladder or a tree.&lt;/li&gt;
&lt;li&gt;The easiest way to create a new chained variable is to copy the variable that you want to base the new one on. In the variable list, click the &lt;strong&gt;Duplicate variable&lt;/strong&gt; icon to the right of the variable entry to create a copy. You can then add on to the query for the parent variable.&lt;/li&gt;
&lt;li&gt;New variables created this way appear at the bottom of the list. You might need to drag it to a different position in the list to get it into a logical order.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;variable-order&#34;&gt;Variable order&lt;/h4&gt;
&lt;p&gt;You can change the orders of variables in the dashboard variable list by clicking the up and down arrows on the right side of each entry. Grafana lists variable dropdowns left to right according to this list, with the variable at the top on the far left.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;List variables that do not have dependencies at the top, before their child variables.&lt;/li&gt;
&lt;li&gt;Each variable should follow the one it is dependent on.&lt;/li&gt;
&lt;li&gt;Remember there is no indication in the UI of which variables have dependency relationships. List the variables in a logical order to make it easy on other users (and yourself).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;complexity-consideration&#34;&gt;Complexity consideration&lt;/h4&gt;
&lt;p&gt;The more layers of dependency you have in variables, the longer it takes to update dashboards after you change variables.&lt;/p&gt;
&lt;p&gt;For example, if you have a series of four linked variables (country, region, server, metric) and you change a root variable value (country), then Grafana must run queries for all the dependent variables before it updates the visualizations in the dashboard.&lt;/p&gt;
&lt;!-- vale Grafana.WordList = NO --&gt;
&lt;h2 id=&#34;filter-variables-with-regex&#34;&gt;Filter variables with regular expressions&lt;/h2&gt;
&lt;!-- vale Grafana.WordList = NO --&gt;
&lt;p&gt;Using the &lt;strong&gt;Regex&lt;/strong&gt; query option, you filter the list of options returned by the variable query or modify the options returned.&lt;/p&gt;
&lt;p&gt;This page shows how to use a regular expression to filter/modify values in the variable dropdown.&lt;/p&gt;
&lt;p&gt;Using the &lt;strong&gt;Regex&lt;/strong&gt; query option, you filter the list of options returned by the Variable query or modify the options returned. For more information, refer to the Mozilla guide on &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Regular expressions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Examples of filtering on the following list of options:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;backend_01
backend_02
backend_03
backend_04&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;filter-so-that-only-the-options-that-end-with-01-or-02-are-returned&#34;&gt;Filter so that only the options that end with &lt;code&gt;01&lt;/code&gt; or &lt;code&gt;02&lt;/code&gt; are returned:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Regex&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;regex&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-regex&#34;&gt;/(01|02)$/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Result:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;backend_01
backend_02&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;filter-and-modify-the-options-using-a-regular-expression-to-capture-group-to-return-part-of-the-text&#34;&gt;Filter and modify the options using a regular expression to capture group to return part of the text:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Regex&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;regex&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-regex&#34;&gt;/.*(01|02)/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Result:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;01
02&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;filter-and-modify---prometheus-example&#34;&gt;Filter and modify - Prometheus Example&lt;/h3&gt;
&lt;p&gt;List of options:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;up{instance=&amp;#34;demo.robustperception.io:9090&amp;#34;,job=&amp;#34;prometheus&amp;#34;} 1 1521630638000
up{instance=&amp;#34;demo.robustperception.io:9093&amp;#34;,job=&amp;#34;alertmanager&amp;#34;} 1 1521630638000
up{instance=&amp;#34;demo.robustperception.io:9100&amp;#34;,job=&amp;#34;node&amp;#34;} 1 1521630638000&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Regex&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;regex&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-regex&#34;&gt;/.*instance=&amp;#34;([^&amp;#34;]*).*/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Result:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;demo.robustperception.io:9090
demo.robustperception.io:9093
demo.robustperception.io:9100&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;filter-and-modify-using-named-text-and-value-capture-groups&#34;&gt;Filter and modify using named text and value capture groups&lt;/h3&gt;
&lt;p&gt;Using named capture groups, you can capture separate &amp;rsquo;text&amp;rsquo; and &amp;lsquo;value&amp;rsquo; parts from the options returned by the variable query. This allows the variable drop-down list to contain a friendly name for each value that can be selected.&lt;/p&gt;
&lt;p&gt;For example, when querying the &lt;code&gt;node_hwmon_chip_names&lt;/code&gt; Prometheus metric, the &lt;code&gt;chip_name&lt;/code&gt; is a lot friendlier than the &lt;code&gt;chip&lt;/code&gt; value. So the following variable query result:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;node_hwmon_chip_names{chip=&amp;#34;0000:d7:00_0_0000:d8:00_0&amp;#34;,chip_name=&amp;#34;enp216s0f0np0&amp;#34;} 1
node_hwmon_chip_names{chip=&amp;#34;0000:d7:00_0_0000:d8:00_1&amp;#34;,chip_name=&amp;#34;enp216s0f0np1&amp;#34;} 1
node_hwmon_chip_names{chip=&amp;#34;0000:d7:00_0_0000:d8:00_2&amp;#34;,chip_name=&amp;#34;enp216s0f0np2&amp;#34;} 1
node_hwmon_chip_names{chip=&amp;#34;0000:d7:00_0_0000:d8:00_3&amp;#34;,chip_name=&amp;#34;enp216s0f0np3&amp;#34;} 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Passed through the following regular expression:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;regex&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-regex&#34;&gt;/chip_name=&amp;#34;(?&amp;lt;text&amp;gt;[^&amp;#34;]&amp;#43;)|chip=&amp;#34;(?&amp;lt;value&amp;gt;[^&amp;#34;]&amp;#43;)/g&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Would produce the following drop-down list:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;text&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-text&#34;&gt;Display Name          Value
------------          -------------------------
enp216s0f0np0         0000:d7:00_0_0000:d8:00_0
enp216s0f0np1         0000:d7:00_0_0000:d8:00_1
enp216s0f0np2         0000:d7:00_0_0000:d8:00_2
enp216s0f0np3         0000:d7:00_0_0000:d8:00_3&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Only &lt;code&gt;text&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt; capture group names are supported.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="add-variables">Add variables&lt;/h1>
&lt;!-- vale Grafana.Spelling = NO -->
&lt;p>The following table lists the types of variables shipped with Grafana.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Variable type&lt;/th>
&lt;th style="text-align: left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">Query&lt;/td>
&lt;td style="text-align: left">Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. &lt;a href="#add-a-query-variable">Add a query variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Custom&lt;/td>
&lt;td style="text-align: left">Define the variable options manually using a comma-separated list. &lt;a href="#add-a-custom-variable">Add a custom variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Text box&lt;/td>
&lt;td style="text-align: left">Display a free text input field with an optional default value. &lt;a href="#add-a-text-box-variable">Add a text box variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Constant&lt;/td>
&lt;td style="text-align: left">Define a hidden constant. &lt;a href="#add-a-constant-variable">Add a constant variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Data source&lt;/td>
&lt;td style="text-align: left">Quickly change the data source for an entire dashboard. &lt;a href="#add-a-data-source-variable">Add a data source variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Interval&lt;/td>
&lt;td style="text-align: left">Interval variables represent time spans. &lt;a href="#add-an-interval-variable">Add an interval variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Ad hoc filters&lt;/td>
&lt;td style="text-align: left">Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). &lt;a href="#add-ad-hoc-filters">Add ad hoc filters&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Switch&lt;/td>
&lt;td style="text-align: left">Display a switch that allows you to toggle between two configurable values for enabled and disabled states. &lt;a href="#add-a-switch-variable">Add a switch variable&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Global variables&lt;/td>
&lt;td style="text-align: left">Built-in variables that can be used in expressions in the query editor. Refer to &lt;a href="#global-variables">Global variables&lt;/a>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Chained variables&lt;/td>
&lt;td style="text-align: left">Variable queries can contain other variables. Refer to &lt;a href="#chained-variables">Chained variables&lt;/a>.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h2 id="enter-general-options">Enter General options&lt;/h2>
&lt;p>You must enter general options for any type of variable that you create.
To create a variable, follow these steps:&lt;/p></description></item><item><title>Manage and inspect variables</title><link>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/inspect-variable/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/inspect-variable/</guid><content><![CDATA[&lt;h1 id=&#34;manage-and-inspect-variables&#34;&gt;Manage and inspect variables&lt;/h1&gt;
&lt;p&gt;In the &lt;strong&gt;Variables&lt;/strong&gt; tab, you can 
    &lt;a href=&#34;/docs/grafana/v12.4/dashboards/variables/add-template-variables/&#34;&gt;add&lt;/a&gt; variables and &lt;a href=&#34;#manage-variables&#34;&gt;manage&lt;/a&gt; existing variables. You can also &lt;a href=&#34;#inspect-variables&#34;&gt;inspect&lt;/a&gt; variables to identify any dependencies between them. &lt;!--whether a variable is being referenced (or used) in other variables or dashboard.--&gt;&lt;/p&gt;
&lt;h2 id=&#34;manage-variables&#34;&gt;Manage variables&lt;/h2&gt;
&lt;p&gt;You can take the following actions in the &lt;strong&gt;Variables&lt;/strong&gt; tab:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Move&lt;/strong&gt; - Move a variable up or down the list using drag and drop.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clone&lt;/strong&gt; - Clone a variable by clicking the clone icon in the set of icons on the right. This creates a copy of the variable with the name of the original variable prefixed with &lt;code&gt;copy_of_&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Delete&lt;/strong&gt; - Delete a variable by clicking the trash icon in the set of icons on the right.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;inspect-variables&#34;&gt;Inspect variables&lt;/h2&gt;
&lt;p&gt;In addition to &lt;a href=&#34;#manage-variables&#34;&gt;managing variables&lt;/a&gt;, the &lt;strong&gt;Variables&lt;/strong&gt; tab lets you easily identify whether variables have any dependencies. To check, click &lt;strong&gt;Show dependencies&lt;/strong&gt; at the bottom of the list, which opens the dependencies diagram:&lt;/p&gt;
&lt;!-- Update and comment this back in when the reference functionality is working again

The variables page lets you easily identify whether a variable is being referenced (or used) in other variables or dashboard. In addition, you can also [add](ref:add) and [manage variables](#manage-variables) on this page.

![Variables list](/static/img/docs/variables-templates/variables-list-7-4.png)

Any variable that is referenced or used has a green check mark next to it, while unreferenced variables have a orange caution icon next to them.

![Variables list](/static/img/docs/variables-templates/variable-not-referenced-7-4.png)

In addition, all referenced variables have a dependency icon next to the green check mark. You can click on the icon to view the dependency map. The dependency map can be moved. You can zoom in out with mouse wheel or track pad equivalent.--&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/variables-templates/dependancy-map-7-4.png&#34;
  alt=&#34;Variables list&#34; width=&#34;772&#34;
     height=&#34;580&#34;/&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="manage-and-inspect-variables">Manage and inspect variables&lt;/h1>
&lt;p>In the &lt;strong>Variables&lt;/strong> tab, you can
&lt;a href="/docs/grafana/v12.4/dashboards/variables/add-template-variables/">add&lt;/a> variables and &lt;a href="#manage-variables">manage&lt;/a> existing variables. You can also &lt;a href="#inspect-variables">inspect&lt;/a> variables to identify any dependencies between them. &lt;!--whether a variable is being referenced (or used) in other variables or dashboard.-->&lt;/p></description></item><item><title>Variable syntax</title><link>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/variable-syntax/</link><pubDate>Fri, 03 Apr 2026 19:43:06 +0000</pubDate><guid>https://grafana.com/docs/grafana/v12.4/visualizations/dashboards/variables/variable-syntax/</guid><content><![CDATA[&lt;h1 id=&#34;variable-syntax&#34;&gt;Variable syntax&lt;/h1&gt;
&lt;p&gt;Panel titles and metric queries can refer to variables using two different syntaxes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$varname&lt;/code&gt;
This syntax is easy to read, but it does not allow you to use a variable in the middle of a word.
&lt;strong&gt;Example:&lt;/strong&gt; apps.frontend.$server.requests.count&lt;/li&gt;
&lt;li&gt;&lt;code&gt;${var_name}&lt;/code&gt; Use this syntax when you want to interpolate a variable in the middle of an expression.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;${var_name:&amp;lt;format&amp;gt;}&lt;/code&gt; This format gives you more control over how Grafana interpolates values. Refer to &lt;a href=&#34;#advanced-variable-format-options&#34;&gt;Advanced variable format options&lt;/a&gt; for more detail on all the formatting types.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[[varname]]&lt;/code&gt; Do not use. Deprecated old syntax, will be removed in a future release.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before queries are sent to your data source the query is &lt;em&gt;interpolated&lt;/em&gt;, meaning the variable is replaced with its current value. During
interpolation, the variable value might be &lt;em&gt;escaped&lt;/em&gt; 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.&lt;/p&gt;
&lt;p&gt;For advanced syntax to override data source default formatting, refer to &lt;a href=&#34;#advanced-variable-format-options&#34;&gt;Advanced variable format options&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;advanced-variable-format-options&#34;&gt;Advanced variable format options&lt;/h2&gt;
&lt;p&gt;The formatting of the variable interpolation depends on the data source, but there are some situations where you might want to change the default formatting.&lt;/p&gt;
&lt;p&gt;For example, the default for the MySql data source is to join multiple values as comma-separated with quotes: &lt;code&gt;&#39;server01&#39;,&#39;server02&#39;&lt;/code&gt;. In some cases, you might want to have a comma-separated string without quotes: &lt;code&gt;server01,server02&lt;/code&gt;. You can make that happen with advanced variable formatting options listed below.&lt;/p&gt;
&lt;h3 id=&#34;general-syntax&#34;&gt;General syntax&lt;/h3&gt;
&lt;p&gt;Syntax: &lt;code&gt;${var_name:option}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Test the formatting options on the &lt;a href=&#34;https://play.grafana.org/d/cJtIfcWiz/template-variable-formatting-options?orgId=1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana Play site&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If any invalid formatting option is specified, then &lt;code&gt;glob&lt;/code&gt; is the default/fallback option.&lt;/p&gt;
&lt;p&gt;An alternative syntax (that might be deprecated in the future) is &lt;code&gt;[[var_name:option]]&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;csv&#34;&gt;CSV&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values as a comma-separated string.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:csv}&amp;#39;
Interpolation result: &amp;#39;test1,test2&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;distributed---opentsdb&#34;&gt;Distributed - OpenTSDB&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values in custom format for OpenTSDB.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:distributed}&amp;#39;
Interpolation result: &amp;#39;test1,servers=test2&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;doublequote&#34;&gt;Doublequote&lt;/h3&gt;
&lt;p&gt;Formats single- and multi-valued variables into a comma-separated string, escapes &lt;code&gt;&amp;quot;&lt;/code&gt; in each value by &lt;code&gt;\&amp;quot;&lt;/code&gt; and quotes each value with &lt;code&gt;&amp;quot;&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:doublequote}&amp;#39;
Interpolation result: &amp;#39;&amp;#34;test1&amp;#34;,&amp;#34;test2&amp;#34;&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;glob---graphite&#34;&gt;Glob - Graphite&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values into a glob (for Graphite queries).&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:glob}&amp;#39;
Interpolation result: &amp;#39;{test1,test2}&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;join&#34;&gt;Join&lt;/h3&gt;
&lt;p&gt;Formats multi-valued variables with a custom delimiter. If no delimiter argument is supplied, they will be combined with &lt;code&gt;,&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#34;test1&amp;#34;, &amp;#34;test2&amp;#34;]
String to interpolate: &amp;#39;${servers:join:&amp;amp;}&amp;#39;
Interpolation result: &amp;#34;test1&amp;amp;test2&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;json&#34;&gt;JSON&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values as a comma-separated string.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:json}&amp;#39;
Interpolation result: &amp;#39;[&amp;#34;test1&amp;#34;, &amp;#34;test2&amp;#34;]&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;lucene---elasticsearch&#34;&gt;Lucene - Elasticsearch&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values in Lucene format for Elasticsearch.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:lucene}&amp;#39;
Interpolation result: &amp;#39;(&amp;#34;test1&amp;#34; OR &amp;#34;test2&amp;#34;)&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;percentencode&#34;&gt;Percentencode&lt;/h3&gt;
&lt;p&gt;Formats single and multi valued variables for use in URL parameters.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;foo()bar BAZ&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:percentencode}&amp;#39;
Interpolation result: &amp;#39;foo%28%29bar%20BAZ%2Ctest2&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;pipe&#34;&gt;Pipe&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values into a pipe-separated string.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1.&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:pipe}&amp;#39;
Interpolation result: &amp;#39;test1.|test2&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;query-parameters&#34;&gt;Query parameters&lt;/h3&gt;
&lt;p&gt;Formats single- and multi-valued variables into their query parameter representation. Example: &lt;code&gt;var-foo=value1&amp;amp;var-foo=value2&lt;/code&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#34;test1&amp;#34;, &amp;#34;test2&amp;#34;]
String to interpolate: &amp;#39;${servers:queryparam}&amp;#39;
Interpolation result: &amp;#34;var-servers=test1&amp;amp;var-servers=test2&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Use the &lt;code&gt;customqueryparam&lt;/code&gt; formatter to customize how the query parameters are formatted. It accepts two optional arguments to specify the parameter name, and a value prefix.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#34;test1&amp;#34;, &amp;#34;test2&amp;#34;]
String to interpolate: &amp;#39;${servers:customqueryparam:v-servers:x-}&amp;#39;
Interpolation result: &amp;#34;v-servers=x-test1&amp;amp;v-servers=x-test2&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;raw&#34;&gt;Raw&lt;/h3&gt;
&lt;p&gt;Doesn&amp;rsquo;t apply any data source-specific formatting to the variable.&lt;/p&gt;
&lt;p&gt;For example, in this case, there&amp;rsquo;s a dashboard with a Prometheus data source and a multi-value variable.
Grafana typically converts the variable values as follows to accommodate Prometheus:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1.&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers}&amp;#39;
Interpolation result: &amp;#39;(test1 | test2)&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using the raw format, the values are returned without that formatting:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1.&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:raw}&amp;#39;
Interpolation result: &amp;#39;test1,test2&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;regex&#34;&gt;Regex&lt;/h3&gt;
&lt;p&gt;Formats variables with multiple values into a regex string.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1.&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:regex}&amp;#39;
Interpolation result: &amp;#39;(test1\.|test2)&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;singlequote&#34;&gt;Singlequote&lt;/h3&gt;
&lt;p&gt;Formats single- and multi-valued variables into a comma-separated string, escapes &lt;code&gt;&#39;&lt;/code&gt; in each value by &lt;code&gt;\&#39;&lt;/code&gt; and quotes each value with &lt;code&gt;&#39;&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#39;test1&amp;#39;, &amp;#39;test2&amp;#39;]
String to interpolate: &amp;#39;${servers:singlequote}&amp;#39;
Interpolation result: &amp;#34;&amp;#39;test1&amp;#39;,&amp;#39;test2&amp;#39;&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;sqlstring&#34;&gt;Sqlstring&lt;/h3&gt;
&lt;p&gt;Formats single- and multi-valued variables into a comma-separated string, escapes &lt;code&gt;&#39;&lt;/code&gt; in each value by &lt;code&gt;&#39;&#39;&lt;/code&gt; and quotes each value with &lt;code&gt;&#39;&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#34;test&amp;#39;1&amp;#34;, &amp;#34;test2&amp;#34;]
String to interpolate: &amp;#39;${servers:sqlstring}&amp;#39;
Interpolation result: &amp;#34;&amp;#39;test&amp;#39;&amp;#39;1&amp;#39;,&amp;#39;test2&amp;#39;&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;text&#34;&gt;Text&lt;/h3&gt;
&lt;p&gt;Formats single- and multi-valued variables into their text representation. For a single variable it will just return the text representation. For multi-valued variables it will return the text representation combined with &lt;code&gt;&#43;&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;servers = [&amp;#34;test1&amp;#34;, &amp;#34;test2&amp;#34;]
String to interpolate: &amp;#39;${servers:text}&amp;#39;
Interpolation result: &amp;#34;test1 &amp;#43; test2&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="variable-syntax">Variable syntax&lt;/h1>
&lt;p>Panel titles and metric queries can refer to variables using two different syntaxes:&lt;/p>
&lt;ul>
&lt;li>&lt;code>$varname&lt;/code>
This syntax is easy to read, but it does not allow you to use a variable in the middle of a word.
&lt;strong>Example:&lt;/strong> apps.frontend.$server.requests.count&lt;/li>
&lt;li>&lt;code>${var_name}&lt;/code> Use this syntax when you want to interpolate a variable in the middle of an expression.&lt;/li>
&lt;li>&lt;code>${var_name:&amp;lt;format&amp;gt;}&lt;/code> This format gives you more control over how Grafana interpolates values. Refer to &lt;a href="#advanced-variable-format-options">Advanced variable format options&lt;/a> for more detail on all the formatting types.&lt;/li>
&lt;li>&lt;code>[[varname]]&lt;/code> Do not use. Deprecated old syntax, will be removed in a future release.&lt;/li>
&lt;/ul>
&lt;p>Before queries are sent to your data source the query is &lt;em>interpolated&lt;/em>, meaning the variable is replaced with its current value. During
interpolation, the variable value might be &lt;em>escaped&lt;/em> 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.&lt;/p></description></item></channel></rss>