<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Add variables on Grafana Labs</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/</link><description>Recent content in Add variables on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v8.4/variables/variable-types/index.xml" rel="self" type="application/rss+xml"/><item><title>Add a query variable</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-query-variable/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-query-variable/</guid><content><![CDATA[&lt;h1 id=&#34;add-a-query-variable&#34;&gt;Add a query variable&lt;/h1&gt;
&lt;p&gt;Query variables allow 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 return numbers or any other data type, you may need to convert them to strings in order 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;tostring&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;h2 id=&#34;query-expressions&#34;&gt;Query expressions&lt;/h2&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;../../../datasources/&#34;&gt;data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Query&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays 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;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-query-options&#34;&gt;Enter Query Options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Data source&lt;/strong&gt; list, select the target data source for the query. For more information about data sources, refer to &lt;a href=&#34;../../../datasources/add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Refresh&lt;/strong&gt; list, select when the variable should update options.
&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 when the dashboard time range changes. Only 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;In the &lt;strong&gt;Query&lt;/strong&gt; field, enter a query.
&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;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;(optional) In the &lt;strong&gt;Regex&lt;/strong&gt; field, type a regex 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 regex&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Sort&lt;/strong&gt; 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 will be used.&lt;/li&gt;
&lt;li&gt;(optional) Enter &lt;a href=&#34;../../variable-selection-options/&#34;&gt;Selection Options&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Preview of values&lt;/strong&gt;, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="add-a-query-variable">Add a query variable&lt;/h1>
&lt;p>Query variables allow 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></description></item><item><title>Add a custom variable</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-custom-variable/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-custom-variable/</guid><content><![CDATA[&lt;h1 id=&#34;add-a-custom-variable&#34;&gt;Add a custom variable&lt;/h1&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;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Custom&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays 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;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-custom-options&#34;&gt;Enter Custom Options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Values separated by comma&lt;/strong&gt; list, enter the values for this 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;(optional) Enter &lt;a href=&#34;../../variable-selection-options/&#34;&gt;Selection Options&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Preview of values&lt;/strong&gt;, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="add-a-custom-variable">Add a custom variable&lt;/h1>
&lt;p>Use a &lt;em>custom&lt;/em> variable for a value that does not change, such as a number or a string.&lt;/p>
&lt;p>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="../chained-variables/">chained variables&lt;/a> rather than other query variables. That would reduce the number of queries Grafana must send when chained variables are updated.&lt;/p></description></item><item><title>Add a text box variable</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-text-box-variable/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-text-box-variable/</guid><content><![CDATA[&lt;h1 id=&#34;add-a-text-box-variable&#34;&gt;Add a text box variable&lt;/h1&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;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Text box&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays 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;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-text-options&#34;&gt;Enter Text options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;(optional) In the &lt;strong&gt;Default value&lt;/strong&gt; field, select the default value for the variable. If you do not enter anything in this field, then Grafana displays an empty text box for users to type text into.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Preview of values&lt;/strong&gt;, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="add-a-text-box-variable">Add a text box variable&lt;/h1>
&lt;p>&lt;em>Text box&lt;/em> 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></description></item><item><title>Add a constant variable</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-constant-variable/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-constant-variable/</guid><content><![CDATA[&lt;h1 id=&#34;add-a-constant-variable&#34;&gt;Add a constant variable&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Constant&lt;/em&gt; variables allow 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 single 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;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Constant&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard. This is the default.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays the variable &lt;strong&gt;Name&lt;/strong&gt; or &lt;strong&gt;Label&lt;/strong&gt; value.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-constant-options&#34;&gt;Enter Constant options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Value&lt;/strong&gt; field, enter the variable value. You can enter letters, numbers, and symbols. You can even use wildcards if you use &lt;a href=&#34;../../advanced-variable-format-options/#raw&#34;&gt;raw format&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Preview of values&lt;/strong&gt;, Grafana displays the current variable value. Review it to ensure it matches what you expect.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="add-a-constant-variable">Add a constant variable&lt;/h1>
&lt;p>&lt;em>Constant&lt;/em> variables allow 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></description></item><item><title>Add a data source variable</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-data-source-variable/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-data-source-variable/</guid><content><![CDATA[&lt;h1 id=&#34;add-a-data-source-variable&#34;&gt;Add a data source variable&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Data source&lt;/em&gt; variables allow 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;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Datasource&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays 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;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-data-source-options&#34;&gt;Enter Data source options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select the target data source for the variable. For more information about data sources, refer to &lt;a href=&#34;../../../datasources/add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Instance name filter&lt;/strong&gt;, enter a regex filter for which data source instances to choose from in the variable value drop-down list. Leave this field empty to display all instances.&lt;/li&gt;
&lt;li&gt;(optional) Enter &lt;a href=&#34;../../variable-selection-options/&#34;&gt;Selection Options&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Preview of values&lt;/strong&gt;, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="add-a-data-source-variable">Add a data source variable&lt;/h1>
&lt;p>&lt;em>Data source&lt;/em> variables allow 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></description></item><item><title>Add an interval variable</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-interval-variable/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-interval-variable/</guid><content><![CDATA[&lt;h1 id=&#34;add-an-interval-variable&#34;&gt;Add an interval variable&lt;/h1&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;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Interval&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays 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;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-interval-options&#34;&gt;Enter Interval Options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;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. 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;/li&gt;
&lt;li&gt;(optional) Turn on the &lt;strong&gt;Auto Option&lt;/strong&gt; if you want to add the &lt;code&gt;auto&lt;/code&gt; option to the list. 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;ul&gt;
&lt;li&gt;&lt;strong&gt;Step count -&lt;/strong&gt; Select the number of times the current time range will be 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 will 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;In &lt;strong&gt;Preview of values&lt;/strong&gt;, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;interval-variable-examples&#34;&gt;Interval variable examples&lt;/h2&gt;
&lt;p&gt;Example using the 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;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;
]]></content><description>&lt;h1 id="add-an-interval-variable">Add an interval variable&lt;/h1>
&lt;p>Use an &lt;em>interval&lt;/em> variable to represents time spans such as &lt;code>1m&lt;/code>,&lt;code>1h&lt;/code>, &lt;code>1d&lt;/code>. 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></description></item><item><title>Add ad hoc filters</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-ad-hoc-filters/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/add-ad-hoc-filters/</guid><content><![CDATA[&lt;h1 id=&#34;add-ad-hoc-filters&#34;&gt;Add ad hoc filters&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Ad hoc filters&lt;/em&gt; allow you to add key/value filters that are automatically added to all metric queries that use the specified data source. Unlike other variables, you do not use ad hoc filters in queries. Instead, you use ad hoc filters to write filters for existing queries.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Ad hoc filter variables only work with Prometheus, Loki, InfluxDB, and Elasticsearch data sources.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;enter-general-options&#34;&gt;Enter General options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the dashboard you want to make a variable for and then click the &lt;strong&gt;Dashboard settings&lt;/strong&gt; (gear) icon at the top of the page.&lt;/li&gt;
&lt;li&gt;On the Variables tab, click &lt;strong&gt;New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;Name&lt;/strong&gt; for your variable.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Type&lt;/strong&gt; list, select &lt;strong&gt;Ad hoc filters&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;(optional) In &lt;strong&gt;Label&lt;/strong&gt;, enter the display name of the variable dropdown. If you don&amp;rsquo;t enter a display name, then the dropdown label will be the variable name.&lt;/li&gt;
&lt;li&gt;Choose a &lt;strong&gt;Hide&lt;/strong&gt; option:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No selection (blank) -&lt;/strong&gt; The variable dropdown displays 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;Label -&lt;/strong&gt; The variable dropdown only displays the selected variable value and a down arrow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable -&lt;/strong&gt; No variable dropdown is displayed on the dashboard.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;enter-options&#34;&gt;Enter Options&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Data source&lt;/strong&gt; list, select the target data source. For more information about data sources, refer to &lt;a href=&#34;../../../datasources/add-a-data-source/&#34;&gt;Add a data source&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add&lt;/strong&gt; to add the variable to the dashboard.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;create-ad-hoc-filters&#34;&gt;Create ad hoc filters&lt;/h2&gt;
&lt;p&gt;Ad hoc filters are one of the most complex and flexible variable options available. Instead of a regular list of variable options, this variable allows you to build a dashboard-wide ad hoc query. Filters you apply in this manner are applied to all panels on the dashboard.&lt;/p&gt;
]]></content><description>&lt;h1 id="add-ad-hoc-filters">Add ad hoc filters&lt;/h1>
&lt;p>&lt;em>Ad hoc filters&lt;/em> allow you to add key/value filters that are automatically added to all metric queries that use the specified data source. Unlike other variables, you do not use ad hoc filters in queries. Instead, you use ad hoc filters to write filters for existing queries.&lt;/p></description></item><item><title>Chained variables</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/chained-variables/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/chained-variables/</guid><content><![CDATA[&lt;h1 id=&#34;chained-variables&#34;&gt;Chained variables&lt;/h1&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 page 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;h2 id=&#34;grafana-play-dashboard-examples&#34;&gt;Grafana Play dashboard examples&lt;/h2&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;Dashboard settings&lt;/strong&gt; (gear icon) and then click &lt;strong&gt;Variables&lt;/strong&gt;. 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/000000002/influxdb-templated?orgId=1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxDB Templated&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples-explained&#34;&gt;Examples explained&lt;/h2&gt;
&lt;p&gt;Variables are useful to reuse dashboards, 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 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;h3 id=&#34;graphite-example&#34;&gt;Graphite example&lt;/h3&gt;
&lt;p&gt;In this example, you have 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;, allowing users to select some or all options presented at any time.&lt;/p&gt;
&lt;h4 id=&#34;app-variable&#34;&gt;app variable&lt;/h4&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Give me 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;h4 id=&#34;server-variable&#34;&gt;server variable&lt;/h4&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Give me 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;h4 id=&#34;more-variables&#34;&gt;More variables&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This example is theoretical. The Graphite server used in the example does not contain CPU metrics.&lt;/p&gt;&lt;/blockquote&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;Show me 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;h3 id=&#34;influxdb-example&#34;&gt;InfluxDB example&lt;/h3&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/000000002/influxdb-templated?orgId=1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InfluxDB Templated&lt;/a&gt;.&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;h4 id=&#34;datacenter-variable&#34;&gt;datacenter variable&lt;/h4&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Give me 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;h4 id=&#34;host-variable&#34;&gt;host variable&lt;/h4&gt;
&lt;p&gt;The query for this variable basically says, &amp;ldquo;Give me 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;h4 id=&#34;more-variables-1&#34;&gt;More variables&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This example is theoretical. The InfluxDB server used in the example does not contain CPU metrics.&lt;/p&gt;&lt;/blockquote&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;Show me 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;h2 id=&#34;best-practices-and-tips&#34;&gt;Best practices and tips&lt;/h2&gt;
&lt;p&gt;The following practices will make your dashboards and variables easier to use.&lt;/p&gt;
&lt;h3 id=&#34;creating-new-linked-variables&#34;&gt;Creating new linked variables&lt;/h3&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;h3 id=&#34;variable-order&#34;&gt;Variable order&lt;/h3&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;h3 id=&#34;complexity-consideration&#34;&gt;Complexity consideration&lt;/h3&gt;
&lt;p&gt;The more layers of dependency you have in variables, the longer it will take 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;
]]></content><description>&lt;h1 id="chained-variables">Chained variables&lt;/h1>
&lt;p>&lt;em>Chained variables&lt;/em>, also called &lt;em>linked variables&lt;/em> or &lt;em>nested variables&lt;/em>, are query variables with one or more other variables in their variable query. This page explains how chained variables work and provides links to example dashboards that use chained variables.&lt;/p></description></item><item><title>Global variables</title><link>https://grafana.com/docs/grafana/v8.4/variables/variable-types/global-variables/</link><pubDate>Sat, 04 Apr 2026 12:26:57 +0000</pubDate><guid>https://grafana.com/docs/grafana/v8.4/variables/variable-types/global-variables/</guid><content><![CDATA[&lt;h1 id=&#34;global-variables&#34;&gt;Global variables&lt;/h1&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;h2 id=&#34;__dashboard&#34;&gt;$__dashboard&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v6.7&#43;. In Grafana 7.1, the variable changed from showing the UID of the current dashboard to the name of the current dashboard.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This variable is the name of the current dashboard.&lt;/p&gt;
&lt;h2 id=&#34;__from-and-__to&#34;&gt;$__from and $__to&lt;/h2&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;blockquote&gt;
&lt;p&gt;This special formatting syntax is only available in Grafana 7.1.2&#43;&lt;/p&gt;&lt;/blockquote&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 args, 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&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The above syntax works with &lt;code&gt;${__to}&lt;/code&gt; as well.&lt;/p&gt;
&lt;p&gt;You can use this variable in URLs as well. For example, 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;h2 id=&#34;__interval&#34;&gt;$__interval&lt;/h2&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 and the graph will look the same and the query will be 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;h2 id=&#34;__interval_ms&#34;&gt;$__interval_ms&lt;/h2&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;h2 id=&#34;__name&#34;&gt;$__name&lt;/h2&gt;
&lt;p&gt;This variable is only available in the Singlestat panel and can be used in the prefix or suffix fields on the Options tab. The variable will be replaced with the series name or alias.&lt;/p&gt;
&lt;h2 id=&#34;__org&#34;&gt;$__org&lt;/h2&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;h2 id=&#34;__user&#34;&gt;$__user&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana v7.1&#43;&lt;/p&gt;&lt;/blockquote&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;h2 id=&#34;__range&#34;&gt;$__range&lt;/h2&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;h2 id=&#34;__rate_interval&#34;&gt;$__rate_interval&lt;/h2&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;../../../datasources/prometheus/&#34;&gt;Prometheus query variables&lt;/a&gt; for details.&lt;/p&gt;
&lt;h2 id=&#34;timefilter-or-__timefilter&#34;&gt;$timeFilter or $__timeFilter&lt;/h2&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;
]]></content><description>&lt;h1 id="global-variables">Global variables&lt;/h1>
&lt;p>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></description></item></channel></rss>