--- aliases: - ../../data-sources/prometheus/template-variables/ description: Using template variables with Prometheus in Grafana keywords: - grafana - prometheus - templates - variables - queries labels: products: - cloud - enterprise - oss menuTitle: Template variables title: Prometheus template variables weight: 400 refs: variables: - pattern: /docs/grafana/ destination: /docs/grafana//dashboards/variables/ - pattern: /docs/grafana-cloud/ destination: /docs/grafana//dashboards/variables/ add-template-variables-add-ad-hoc-filters: - pattern: /docs/grafana/ destination: /docs/grafana//dashboards/variables/add-template-variables/#add-ad-hoc-filters - pattern: /docs/grafana-cloud/ destination: /docs/grafana//dashboards/variables/add-template-variables/#add-ad-hoc-filters add-template-variables: - pattern: /docs/grafana/ destination: /docs/grafana//dashboards/variables/add-template-variables/ - pattern: /docs/grafana-cloud/ destination: /docs/grafana//dashboards/variables/add-template-variables/ add-template-variables-global-variables: - pattern: /docs/grafana/ destination: /docs/grafana//dashboards/variables/add-template-variables/#global-variables - pattern: /docs/grafana-cloud/ destination: /docs/grafana//dashboards/variables/add-template-variables/#global-variables --- # Prometheus template 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. For an introduction to templating and template variables, see [Templating](ref:variables) and [Add and manage variables](ref:add-template-variables). ## Use query variables 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: | Query Type | Input(\* required) | Description | Used API endpoints | | --------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | | `Label names` | `metric` | Returns a list of all label names matching the specified `metric` regex. | /api/v1/labels | | `Label values` | `label`\*, `metric` | Returns a list of label values for the `label` in all metrics or the optional metric. | /api/v1/label/`label`/values or /api/v1/series | | `Metrics` | `metric` | Returns a list of metrics matching the specified `metric` regex. | /api/v1/label/\_\_name\_\_/values | | `Query result` | `query` | Returns a list of Prometheus query result for the `query`. | /api/v1/query | | `Series query` | `metric`, `label` or both | Returns a list of time series associated with the entered data. | /api/v1/series | | `Classic query` | classic query string | Deprecated, classic version of variable query editor. Enter a string with the query type using a syntax like the following: `label_values(,