mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
Docs: Add data source, interval, and ad hoc variable tasks (#26504)
* Create add-data-source-variable.md * Update templates-and-variables.md * Update menu.yaml * Update add-interval-variable.md * Update menu.yaml * Update templates-and-variables.md * Update add-interval-variable.md * Update add-interval-variable.md * ad hoc filters * Update templates-and-variables.md * Update templates-and-variables.md * Update add-ad-hoc-filters.md
This commit is contained in:
parent
7b218b7198
commit
a13a9e2ef6
@ -261,6 +261,12 @@
|
||||
name: Add text box variable
|
||||
- link: /variables/add-constant-variable/
|
||||
name: Add constant variable
|
||||
- link: /variables/add-data-source-variable/
|
||||
name: Add data source variable
|
||||
- link: /variables/add-interval-variable/
|
||||
name: Add interval variable
|
||||
- link: /variables/add-ad-hoc-filters/
|
||||
name: Add ad hoc filters
|
||||
- name: Selection options
|
||||
link: /variables/variable-selection-options/
|
||||
- name: Value groups/tags
|
||||
|
33
docs/sources/variables/add-ad-hoc-filters.md
Normal file
33
docs/sources/variables/add-ad-hoc-filters.md
Normal file
@ -0,0 +1,33 @@
|
||||
+++
|
||||
title = "Add ad hoc filters"
|
||||
type = "docs"
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
|
||||
# Add ad hoc filters
|
||||
|
||||
_Ad hoc filters_ 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.
|
||||
|
||||
> **Note:** Ad hoc filter variables only work with InfluxDB, Prometheus, and Elasticsearch data sources.
|
||||
|
||||
## Enter General options
|
||||
|
||||
1. Navigate to the dashboard you want to make a variable for and then click the **Dashboard settings** (gear) icon at the top of the page.
|
||||
1. On the Variables tab, click **New**.
|
||||
1. Enter a **Name** for your variable.
|
||||
1. In the **Type** list, select **Ad hoc filters**.
|
||||
1. (optional) In **Label**, enter the display name of the variable dropdown. If you don't enter a display name, then the dropdown label will be the variable name.
|
||||
1. Choose a **Hide** option:
|
||||
- **No selection (blank) -** The variable dropdown displays the variable **Name** or **Label** value. This is the default.
|
||||
- **Label -** The variable dropdown only displays the selected variable value and a down arrow.
|
||||
- **Variable -** No variable dropdown is displayed on the dashboard.
|
||||
|
||||
## 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. Click **Add** to add the variable to the dashboard.
|
||||
|
||||
## Create ad hoc filters
|
||||
|
||||
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.
|
30
docs/sources/variables/add-data-source-variable.md
Normal file
30
docs/sources/variables/add-data-source-variable.md
Normal file
@ -0,0 +1,30 @@
|
||||
+++
|
||||
title = "Add a data source variable"
|
||||
type = "docs"
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
+++
|
||||
|
||||
# Add a data source variable
|
||||
|
||||
_Data source_ 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.
|
||||
|
||||
## Enter General options
|
||||
|
||||
1. Navigate to the dashboard you want to make a variable for and then click the **Dashboard settings** (gear) icon at the top of the page.
|
||||
1. On the Variables tab, click **New**.
|
||||
1. Enter a **Name** for your variable.
|
||||
1. In the **Type** list, select **Datasource**.
|
||||
1. (optional) In **Label**, enter the display name of the variable dropdown. If you don't enter a display name, then the dropdown label will be the variable name.
|
||||
1. Choose a **Hide** option:
|
||||
- **No selection (blank) -** The variable dropdown displays the variable **Name** or **Label** value. This is the default.
|
||||
- **Label -** The variable dropdown only displays the selected variable value and a down arrow.
|
||||
- **Variable -** No variable dropdown is displayed on the dashboard.
|
||||
|
||||
## 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. (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. 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,20 +3,45 @@ title = "Add an interval variable"
|
||||
type = "docs"
|
||||
[menu.docs]
|
||||
weight = 500
|
||||
draft = "true"
|
||||
+++
|
||||
|
||||
# Add an interval variable
|
||||
|
||||
> Note: This is a draft topic, not included in the live build.
|
||||
Use an _interval_ variable to represents time spans such as `1m`,`1h`, `1d`. You can think of them as a dashboard-wide "group by time" 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.
|
||||
|
||||
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).
|
||||
|
||||
Use the `Interval` type to create a variable that represents a time span (eg. `1m`,`1h`, `1d`). There is also a special `auto` option that will change depending on the current time range. You can specify how many times the current time range should be divided to calculate the current `auto` timespan.
|
||||
## Enter General options
|
||||
|
||||
This variable type is useful as a parameter to group by time (for InfluxDB), Date histogram interval (for Elasticsearch) or as a *summarize* function parameter (for Graphite).
|
||||
1. Navigate to the dashboard you want to make a variable for and then click the **Dashboard settings** (gear) icon at the top of the page.
|
||||
1. On the Variables tab, click **New**.
|
||||
1. Enter a **Name** for your variable.
|
||||
1. In the **Type** list, select **Interval**.
|
||||
1. (optional) In **Label**, enter the display name of the variable dropdown. If you don't enter a display name, then the dropdown label will be the variable name.
|
||||
1. Choose a **Hide** option:
|
||||
- **No selection (blank) -** The variable dropdown displays the variable **Name** or **Label** value. This is the default.
|
||||
- **Label -** The variable dropdown only displays the selected variable value and a down arrow.
|
||||
- **Variable -** No variable dropdown is displayed on the dashboard.
|
||||
|
||||
Example using the template variable `myinterval` of type `Interval` in a graphite function:
|
||||
## Enter Interval Options
|
||||
|
||||
1. In the **Values** field, enter the time range intervals that you want to appear in the variable drop-down list. The following time units are supported: `s (seconds)`, `m (minutes)`, `h (hours)`, `d (days)`, `w (weeks)`, `M (months)`, and `y (years)`. You can also accept or edit the default values: `1m,10m,30m,1h,6h,12h,1d,7d,14d,30d`.
|
||||
1. (optional) Turn on the **Auto Option** if you want to add the `auto` option to the list. This option allows you to specify how many times the current time range should be divided to calculate the current `auto` time span. If you turn it on, then two more options appear:
|
||||
- **Step count -** Select the number of times the current time range will be divided to calculate the value, similar to the **Max data points** query option. For example, if the current visible time range is 30 minutes, then the `auto` interval groups the data into 30 one-minute increments. The default value is 30 steps.
|
||||
- **Min Interval -** 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.
|
||||
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.
|
||||
|
||||
## Interval variable examples
|
||||
|
||||
Example using the template variable `myinterval` in a Graphite function:
|
||||
|
||||
```
|
||||
summarize($myinterval, sum, false)
|
||||
```
|
||||
|
||||
A more complex Graphite example, from the [Graphite Template Nested Requests panel](https://play.grafana.org/d/000000056/graphite-templated-nested?editPanel=2&orgId=1):
|
||||
|
||||
```
|
||||
groupByNode(summarize(movingAverage(apps.$app.$server.counters.requests.count, 5), '$interval', 'sum', false), 2, 'sum')
|
||||
```
|
@ -96,25 +96,15 @@ Define a hidden constant. For instructions, refer to [Add a constant variable]({
|
||||
|
||||
### Data source
|
||||
|
||||
Data source variables allow you to quickly change the data source for an entire dashboard. Useful if you have multiple instances of a data source in for example different environments.
|
||||
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.
|
||||
|
||||
You can use the `Interval` type to create a variable that represents a time span (eg. `1m`,`1h`, `1d`). There is also a special `auto` option that will change depending on the current time range. You can specify how many times the current time range should be divided to calculate the current `auto` timespan.
|
||||
|
||||
This variable type is useful as a parameter to group by time (for InfluxDB), Date histogram interval (for Elasticsearch) or as a *summarize* function parameter (for Graphite).
|
||||
|
||||
Example using the template variable `myinterval` of type `Interval` in a Graphite function:
|
||||
|
||||
```
|
||||
summarize($myinterval, sum, false)
|
||||
```
|
||||
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
|
||||
|
||||
Ad hoc filter variables only work with InfluxDB, Prometheus, and Elasticsearch data sources. This variable type allows you to add key/value filters that are automatically added to all metric queries that use the specified data source.
|
||||
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 best practices
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user