From 2b84887e5011c1dca7cf83763e817365d40a1647 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:46:49 +0100 Subject: [PATCH] [v9.5.x] update prometheus template variables doc (#69414) update prometheus template variables doc (#69335) * edits for clarity * added 2 new sections on query variable options * Update docs/sources/datasources/prometheus/template-variables/index.md Co-authored-by: Brendan O'Handley --------- Co-authored-by: Brendan O'Handley (cherry picked from commit 5ac56bcb2866047d16551144d53d284400e0b884) Co-authored-by: lwandz13 <126723338+lwandz13@users.noreply.github.com> --- .../prometheus/template-variables/index.md | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/sources/datasources/prometheus/template-variables/index.md b/docs/sources/datasources/prometheus/template-variables/index.md index 8004fd233a9..37433015e3e 100644 --- a/docs/sources/datasources/prometheus/template-variables/index.md +++ b/docs/sources/datasources/prometheus/template-variables/index.md @@ -15,15 +15,14 @@ weight: 400 # Prometheus template variables -Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables. +Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables. Grafana refers to such variables as **template** variables. Grafana lists these variables in dropdown select boxes at the top of the dashboard to help you change the data displayed in your dashboard. -Grafana refers to such variables as template variables. -For an introduction to templating and template variables, refer to the [Templating]({{< relref "../../../dashboards/variables" >}}) and [Add and manage variables]({{< relref "../../../dashboards/variables/add-template-variables" >}}) documentation. +For an introduction to templating and template variables, see [Templating]({{< relref "../../../dashboards/variables" >}}) and [Add and manage variables]({{< relref "../../../dashboards/variables/add-template-variables" >}}). ## Use query variables -Use variables of the type _Query_ to query Prometheus for a list of metrics, labels, or label values. +You have the option to use several different variable types, but variables of the type `Query` will query Prometheus for a list of metrics, labels, label values, a query result or a series. Select a Prometheus data source query type and enter the required inputs: @@ -37,6 +36,26 @@ Select a Prometheus data source query type and enter the required inputs: For details on _metric names_, _label names_, and _label values_, refer to the [Prometheus documentation](http://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). +### Query options + +Under the query variable type, you can set the following query options: + +| Option | Description | +| --------------------- | ------------------------------------------------------------------------------------------------------- | +| **Data source** | Select your data source from the dropdown list. | +| **Select query type** | Options are `default`, `value` and `metric name`. Each query type hits a different Prometheus endpoint. | +| **Regex** | Optional, if you want to extract part of a series name or metric node segment. | +| **Sort** | Default is `disabled`. Options include `alphabetical`, `numerical` and `alphabetical case-sensitive`. | +| **Refresh** | When to update the values for the variable. Options are `On dashboard load` and `On time range change`. | + +### Selection options + +The following selection options are available: + +- **Multi-value** - Check this option to enable multiple values to be selected at the same time. + +- **Include All option** - Check this option to include all variables. + ### Use interval and range variables You can use some global built-in variables in query variables, for example, `$__interval`, `$__interval_ms`, `$__range`, `$__range_s` and `$__range_ms`.