Docs: Organize variables (#26738)
* Moved files to folder and updated links * fixed links * Update _index.md * Update templates-and-variables.md
This commit is contained in:
@@ -38,13 +38,9 @@ Variable values are always synced to the URL using the syntax `var-<varname>=val
|
||||
|
||||
## Examples of templates and variables
|
||||
|
||||
To see variable and template examples, go to any of the dashboards listed below.
|
||||
To see variable and template examples, go to any of the dashboards listed in [Variable examples]({{< relref "variable-examples.md" >}}).
|
||||
|
||||
- [Elasticsearch Templated dashboard](https://play.grafana.org/dashboard/db/elasticsearch-templated)
|
||||
- [Graphite Templated Nested dashboard](https://play.grafana.org/dashboard/db/graphite-templated-nested)
|
||||
- [InfluxDB Templated dashboard](https://play.grafana.org/dashboard/db/influxdb-templated)
|
||||
|
||||
Variables are listed in dropdown lists across the top of the screen. Select different variables to see how the visualizations change.
|
||||
Variables are listed in drop-down lists across the top of the screen. Select different variables to see how the visualizations change.
|
||||
|
||||
To see variable settings, navigate to **Dashboard Settings > Variables**. Click a variable in the list to see its settings.
|
||||
|
||||
@@ -70,41 +66,20 @@ For advanced syntax to override data source default formatting, refer to [Advanc
|
||||
|
||||
## Variable types
|
||||
|
||||
Grafana has global built-in variables that can be used in expressions in the query editor. Refer to [Global variables]({{< relref "global-variables" >}}) for more information.
|
||||
Grafana uses the following types of variables.
|
||||
|
||||
You can also define the following types of variables in Grafana.
|
||||
|
||||
### Query
|
||||
|
||||
Write a data source query that might return a list of metric names, tag values, keys, server names, sensor IDs, data centers, and so on.
|
||||
|
||||
For instructions, refer to [Add a query variable]({{< relref "add-query-variable.md" >}}).
|
||||
|
||||
Variable queries can contain other variables. For more information, refer to [Chained variables]({{< relref "chained-variables.md" >}}).
|
||||
|
||||
### Custom
|
||||
|
||||
Define the variable options manually using a comma-separated list. For instructions, refer to [Add a custom variable]({{< relref "add-custom-variable.md" >}}).
|
||||
|
||||
### Text box
|
||||
|
||||
Display a free text input field with an optional default value. For instructions, refer to [Add a text box variable]({{< relref "add-text-box-variable.md" >}}).
|
||||
|
||||
### Constant
|
||||
|
||||
Define a hidden constant. For instructions, refer to [Add a constant variable]({{< relref "add-constant-variable.md" >}}).
|
||||
|
||||
### Data source
|
||||
|
||||
Quickly change the data source for an entire dashboard. For instructions, refer to [Add a data source variable]({{< relref "add-data-source-variable.md" >}}).
|
||||
|
||||
### Interval
|
||||
|
||||
Interval variables represent time spans. Instead of hard-coding a group by time or date histogram interval, use an interval variable. For instructions, refer to [Add an interval variable]({{< relref "add-interval-variable.md" >}}).
|
||||
|
||||
### Ad hoc filters
|
||||
|
||||
Add key/value filters that are automatically added to all metric queries that use the specified data source. Ad hoc filter variables only work with InfluxDB, Prometheus, and Elasticsearch data sources. For instructions, refer to [Add ad hoc filters]({{< relref "add-ad-hoc-filters.md" >}}).
|
||||
| Variable type | Description |
|
||||
|:---|:---|
|
||||
| Query | Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. [Add a query variable]({{< relref "variable-types/add-query-variable.md" >}}). |
|
||||
| Custom | Define the variable options manually using a comma-separated list. [Add a custom variable]({{< relref "variable-types/add-custom-variable.md" >}}). |
|
||||
| Text box | Display a free text input field with an optional default value. [Add a text box variable]({{< relref "variable-types/add-text-box-variable.md" >}}). |
|
||||
| Constant | Define a hidden constant. [Add a constant variable]({{< relref "variable-types/add-constant-variable.md" >}}). |
|
||||
| Data source | Quickly change the data source for an entire dashboard. [Add a data source variable]({{< relref "variable-types/add-data-source-variable.md" >}}). |
|
||||
| Interval | Interval variables represent time spans. [Add an interval variable]({{< relref "variable-types/add-interval-variable.md" >}}). |
|
||||
| Ad hoc filters | Key/value filters that are automatically added to all metric queries for a data source (InfluxDB, Prometheus, and Elasticsearch only). [Add ad hoc filters]({{< relref "variable-types/add-ad-hoc-filters.md" >}}). |
|
||||
| Global variables | Built-in variables that can be used in expressions in the query editor. Refer to [Global variables]({{< relref "variable-types/global-variables" >}}). |
|
||||
| Chained variables | Variable queries can contain other variables. Refer to [Chained variables]({{< relref "variable-types/chained-variables.md" >}}). |
|
||||
| URL variables | You can use variables in data links to link to specific portions of your visualizations. Refer to [Data links]({{< relref "../linking/data-links.md" >}}). |
|
||||
|
||||
## Variable best practices
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
+++
|
||||
title = "Variables types"
|
||||
type = "docs"
|
||||
[menu.docs]
|
||||
weight = 300
|
||||
+++
|
||||
|
||||
# Variables types
|
||||
|
||||
Grafana uses several types of variables.
|
||||
|
||||
| Variable type | Description |
|
||||
|:---|:---|
|
||||
| Query | Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. [Add a query variable]({{< relref "add-query-variable.md" >}}). |
|
||||
| Custom | Define the variable options manually using a comma-separated list. [Add a custom variable]({{< relref "add-custom-variable.md" >}}). |
|
||||
| Text box | Display a free text input field with an optional default value. [Add a text box variable]({{< relref "add-text-box-variable.md" >}}). |
|
||||
| Constant | Define a hidden constant. [Add a constant variable]({{< relref "add-constant-variable.md" >}}). |
|
||||
| Data source | Quickly change the data source for an entire dashboard. [Add a data source variable]({{< relref "add-data-source-variable.md" >}}). |
|
||||
| Interval | Interval variables represent time spans. [Add an interval variable]({{< relref "add-interval-variable.md" >}}). |
|
||||
| Ad hoc filters | Key/value filters that are automatically added to all metric queries for a data source (InfluxDB, Prometheus, and Elasticsearch only). [Add ad hoc filters]({{< relref "add-ad-hoc-filters.md" >}}). |
|
||||
| Global variables | Built-in variables that can be used in expressions in the query editor. Refer to [Global variables]({{< relref "global-variables" >}}). |
|
||||
| Chained variables | Variable queries can contain other variables. Refer to [Chained variables]({{< relref "chained-variables.md" >}}). |
|
||||
| URL variables | You can use variables in data links to link to specific portions of your visualizations. Refer to [Data links]({{< relref "../../linking/data-links.md" >}}). |
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add ad hoc filters"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-ad-hoc-filters.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
@@ -25,7 +26,7 @@ _Ad hoc filters_ allow you to add key/value filters that are automatically added
|
||||
|
||||
## Enter Options
|
||||
|
||||
1. In the **Data source** list, select the target data source. For more information about data sources, refer to [Add a data source]({{< relref "../features/datasources/add-a-data-source.md" >}}).
|
||||
1. In the **Data source** list, select the target data source. For more information about data sources, refer to [Add a data source]({{< relref "../../features/datasources/add-a-data-source.md" >}}).
|
||||
1. Click **Add** to add the variable to the dashboard.
|
||||
|
||||
## Create ad hoc filters
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add a constant variable"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-constant-variable.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
@@ -27,6 +28,6 @@ Constant variables are useful when you have complex values that you need to incl
|
||||
|
||||
## Enter Constant options
|
||||
|
||||
1. In the **Value** field, enter the variable value. You can enter letters, numbers, and symbols. You can even use wildcards if you use [raw format]({{< relref "advanced-variable-format-options.md#raw" >}}).
|
||||
1. In the **Value** field, enter the variable value. You can enter letters, numbers, and symbols. You can even use wildcards if you use [raw format]({{< relref "../advanced-variable-format-options.md#raw" >}}).
|
||||
1. In **Preview of values**, Grafana displays the current variable value. Review it to ensure it matches what you expect.
|
||||
1. Click **Add** to add the variable to the dashboard.
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add a custom variable"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-custom-variable.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
@@ -9,7 +10,7 @@ weight = 500
|
||||
|
||||
Use a _custom_ variable for values that do not change. This might be numbers, strings, or even other variables.
|
||||
|
||||
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 [chained variables](chained-variables.md) rather than other query variables. That would reduce the number of queries Grafana must send when chained variables are updated.
|
||||
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 [chained variables]({{< relref "chained-variables.md" >}}) rather than other query variables. That would reduce the number of queries Grafana must send when chained variables are updated.
|
||||
|
||||
## Enter General options
|
||||
|
||||
@@ -26,6 +27,6 @@ For example, if you have server names or region names that never change, then yo
|
||||
## Enter Custom Options
|
||||
|
||||
1. In the **Values separated by comma** list, enter the values for this variable in a comma-separated list. You can include numbers, strings, or other variables.
|
||||
1. (optional) Enter [Selection Options]({{< relref "variable-selection-options.md" >}}).
|
||||
1. (optional) Enter [Selection Options]({{< relref "../variable-selection-options.md" >}}).
|
||||
1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.
|
||||
1. Click **Add** to add the variable to the dashboard.
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add a data source variable"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-data-source-variable.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
@@ -23,8 +24,8 @@ _Data source_ variables allow you to quickly change the data source for an entir
|
||||
|
||||
## Enter Data source options
|
||||
|
||||
1. In the **Type** list, select the target data source for the variable. For more information about data sources, refer to [Add a data source]({{< relref "../features/datasources/add-a-data-source.md" >}}).
|
||||
1. In the **Type** list, select the target data source for the variable. For more information about data sources, refer to [Add a data source]({{< relref "../../features/datasources/add-a-data-source.md" >}}).
|
||||
1. (optional) In **Instance name filter**, 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.
|
||||
1. (optional) Enter [Selection Options]({{< relref "variable-selection-options.md" >}}).
|
||||
1. (optional) Enter [Selection Options]({{< relref "../variable-selection-options.md" >}}).
|
||||
1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.
|
||||
1. Click **Add** to add the variable to the dashboard.
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add an interval variable"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-interval-variable.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add a query variable"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-query-variable.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
@@ -13,7 +14,7 @@ Query expressions can contain references to other variables and in effect create
|
||||
|
||||
## Query expressions
|
||||
|
||||
Query expressions are different for each data source. For more information, refer to the documentation for your [data source]({{< relref "../features/datasources/_index.md" >}}).
|
||||
Query expressions are different for each data source. For more information, refer to the documentation for your [data source]({{< relref "../../features/datasources/_index.md" >}}).
|
||||
|
||||
## Enter General options
|
||||
|
||||
@@ -29,7 +30,7 @@ Query expressions are different for each data source. For more information, refe
|
||||
|
||||
## Enter Query Options
|
||||
|
||||
1. In the **Data source** list, select the target data source for the query. For more information about data sources, refer to [Add a data source]({{< relref "../features/datasources/add-a-data-source.md" >}}).
|
||||
1. In the **Data source** list, select the target data source for the query. For more information about data sources, refer to [Add a data source]({{< relref "../../features/datasources/add-a-data-source.md" >}}).
|
||||
1. In the **Refresh** list, select when the variable should update options.
|
||||
- **Never -** Variables queries are cached and values are not updated. This is fine if the values never change, but problematic if they are dynamic and change a lot.
|
||||
- **On Dashboard Load -** 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.
|
||||
@@ -37,9 +38,9 @@ Query expressions are different for each data source. For more information, refe
|
||||
1. In the **Query** field, enter a query.
|
||||
- The query field varies according to your data source. Some data sources have custom query editors.
|
||||
- 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.
|
||||
1. (optional) In the **Regex** 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 [Filter variables with regex]({{< relref "filter-variables-with-regex.md" >}}).
|
||||
1. (optional) In the **Regex** 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 [Filter variables with regex]({{< relref "../filter-variables-with-regex.md" >}}).
|
||||
1. In the **Sort** list, select the sort order for values to be displayed in the dropdown list. The default option, **Disabled**, means that the order of options returned by your data source query will be used.
|
||||
1. (optional) Enter [Selection Options]({{< relref "variable-selection-options.md" >}}).
|
||||
1. (optional) Enter [Value groups/tags]({{< relref "variable-value-tags.md" >}}).
|
||||
1. (optional) Enter [Selection Options]({{< relref "../variable-selection-options.md" >}}).
|
||||
1. (optional) Enter [Value groups/tags]({{< relref "../variable-value-tags.md" >}}).
|
||||
1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.
|
||||
1. Click **Add** to add the variable to the dashboard.
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
+++
|
||||
title = "Add a text box variable"
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/add-text-box-variable.md"]
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
title = "Chained variables"
|
||||
keywords = ["grafana", "templating", "variable", "nested", "chained", "linked"]
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/chained-variables.md"]
|
||||
[menu.docs]
|
||||
weight = 600
|
||||
+++
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
title = "Global variables"
|
||||
keywords = ["grafana", "templating", "documentation", "guide", "template", "variable", "global", "standard"]
|
||||
type = "docs"
|
||||
aliases = ["/docs/grafana/latest/variables/global-variables.md"]
|
||||
[menu.docs]
|
||||
name = "global-variables"
|
||||
parent = "variables"
|
||||
+2
-1
@@ -1,12 +1,13 @@
|
||||
+++
|
||||
title = "URL variables"
|
||||
keywords = ["grafana", "url variables", "documentation", "variables"]
|
||||
aliases = ["/docs/grafana/latest/variables/url-variables.md"]
|
||||
type = "docs"
|
||||
+++
|
||||
|
||||
# URL variables
|
||||
|
||||
You can use variables in data links to link to specific portions of your visualizations. For more information about data links, refer to [Data links]({{< relref "../linking/data-links.md" >}}).
|
||||
You can use variables in data links to link to specific portions of your visualizations. For more information about data links, refer to [Data links]({{< relref "../../linking/data-links.md" >}}).
|
||||
|
||||
> **Note:** These variables changed in 6.4 so if you have an older version of Grafana please use the version picker to select
|
||||
docs for an older version of Grafana.
|
||||
Reference in New Issue
Block a user