mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
Update templating.md
This commit is contained in:
parent
1b12e3fbf9
commit
0c25c1f0ca
@ -8,40 +8,48 @@ page_keywords: grafana, templating, variables, guide, documentation
|
||||
![](/img/v2/templating_var_list.png)
|
||||
|
||||
## Overview
|
||||
Templating allows you to create dashboard variables that can be used in your metric queries, series
|
||||
names and panel titles. Use this feature to create generic dashboards that can quickly be
|
||||
changed to show graphs for different servers or metrics.
|
||||
|
||||
You find this feature in the dashboard cog dropdown menu.
|
||||
Templating allows your Dashboards to be more interactive and dynamic. You can create Template variables that can be used practically anywhere in Grafana: metric queries on individual panels, series names, and titles.
|
||||
|
||||
Quickly change Template variables to show different graphs and metrics for different server and applications.
|
||||
|
||||
You can find and configure the Templating for a particular Dashboard by clicking the dropdown cog on the top of the Dashboard when viewing it.
|
||||
|
||||
## Variable types
|
||||
There are three different types of template variables. They can all be used in the
|
||||
same way but they differ in how the list variables values is created.
|
||||
|
||||
There are three different types of Template variables. They can all be used to create dynamic variables that you can use throughout the Dashboard. They differ slightly in how they create values.
|
||||
|
||||
### Query
|
||||
This is the most common type of variable. It allows you to create a variable
|
||||
with values fetched directly from a data source via a metric exploration query.
|
||||
|
||||
For example a query like `prod.servers.*` will fill the variable with all possible
|
||||
values that exists in the wildcard position (Graphite example).
|
||||
> The Query type is often Data Source specific. Please consult the appropriate documentation for your particular Data Source.
|
||||
|
||||
You can also create nested variables that use other variables in their definition. For example
|
||||
`apps.$app.servers.*` uses the variable `$app` in its query definition.
|
||||
This is the most common type of Template variable. Using the Query type to generate a dynamic list of variables, simply by allowing Grafana to explore your Data Source metric namespace when the Dashboard loads.
|
||||
|
||||
> For examples of template queries appropriate for your data source checkout the documentation
|
||||
> page for your data source.
|
||||
For example a query like `prod.servers.*` will fill the variable with all possible values that exists in that wildcard position (in the case of the Graphite Data Source).
|
||||
|
||||
You can even create nested variables that use other variables in their definition. For example `apps.$app.servers.*` uses the variable `$app` in its own query definition.
|
||||
|
||||
You can utilize the special "All" value to allow the Dashboard user to query for every single Query variable returned. Grafana will automatically translate All into the appropriate format for your Data Source.
|
||||
|
||||
As of Grafana 2.1, it is now possible to select a subset of Query Template variables (previously it was possible to select an individual value or 'All', not multiple values that were less than All). This is accomplished via the Multi-Select option. If enabled, the Dashboard user will be able to enable and disable individual variables.
|
||||
|
||||
### Interval
|
||||
This variable type is useful for time ranges like `1m`,`1h`, `1d`. There is also an 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` range.
|
||||
|
||||
Use the Interval type to create Template variables aroundr time ranges (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` range.
|
||||
|
||||
![](/img/v2/templated_variable_parameter.png)
|
||||
|
||||
### Custom
|
||||
This variable type allow you to manually specify all the different values as a comma seperated
|
||||
string.
|
||||
|
||||
Use the Custom type to manually create Template variables around explicit values that are hard coded in the Dashboard and not dependent on any Data Source. You can specify multiple Custom Template values by separating them with a comma.
|
||||
|
||||
## Utilizing Template Variables with Repeating Panels and Repeating Rows
|
||||
|
||||
Template Variables can be very useful to dynamically change what you're visualizing on a given panel. Sometimes, you might want to create entire new Panels (or Rows) based on what Template Variables have been selected. This is now possible in Grafana 2.1.
|
||||
|
||||
Once you've got your Template variables (of any type) configured the way you'd like, check out the Repeating Panels and Repeating Row documentatione
|
||||
|
||||
## Screencast - Templated Graphite Queries
|
||||
|
||||
<iframe width="561" height="315" src="//www.youtube.com/embed/FhNUrueWwOk?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user