mirror of
https://github.com/grafana/grafana.git
synced 2025-09-25 19:24:22 +08:00

* Docs: Revise data source index * Docs: Consolidate data source administration docs * Docs: Revise panels docs related to data sources * Docs: Revise Alertmanager data source * Docs: Reorganize AWS CloudWatch data source docs * Docs: Reorganize Azure Monitor data source docs * Docs: Move azuremonitor to azure-monitor * Docs: Revise Elasticsearch docs * Docs: Move Elasticsearch index into bundle * Docs: Revise GCM docs * Docs: Revise Graphite docs * Docs: Move Graphite index into bundle * Docs: Revise InfluxDB docs * Docs: Revise Jaeger docs * Docs: Move Jaeger index into bundle * Docs: Revise Loki docs * Docs: Move Loki index into bundle * Docs: Revise MS SQL docs * Docs: Move MS SQL index into bundle * Docs: Revise Prometheus docs * Docs: Move Prometheus index into bundle * Docs: Revise Tempo docs * Docs: Move Tempo index into bundle * Docs: Revise TestData DB docs * Docs: Move TestData DB index into bundle * Docs: Revise Zipkin docs * Docs: Move Zipkin index into bundle * Docs: Move other data sources' index pages into bundles * Docs: Revise frontmatter * Fixing hugo markdown errors * Docs: Add query editor and template var sections to overview doc * Docs: Remove CTAs across data source docs * Docs: Remove CTA * Docs: Remove CTA * Docs: Fix links, images, typos, and usage consistency. * Docs: Fix typos * Docs: Fix CI issues * Update docs/sources/datasources/_index.md Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * Update docs/sources/datasources/_index.md Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * Docs: Fix query editor links * Update docs/sources/panels-visualizations/_index.md Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * Update docs/sources/panels-visualizations/_index.md Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * Docs: Rebundle child pages per writers' toolkit * Docs: Fix prettier for CI * Docs: Fix relrefs from outside data sources docs * Docs: Fix broken relrefs within datasources * Docs: Fix relrefs to data sources docs * Fixed some more refs Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
50 lines
2.4 KiB
Markdown
50 lines
2.4 KiB
Markdown
---
|
|
aliases:
|
|
- /docs/grafana/latest/data-sources/loki/template-variables/
|
|
description: Guide for using template variables when querying the Loki data source
|
|
keywords:
|
|
- grafana
|
|
- loki
|
|
- logs
|
|
- queries
|
|
- template
|
|
- variable
|
|
menuTitle: Template variables
|
|
title: Loki template variables
|
|
weight: 300
|
|
---
|
|
|
|
# Loki template variables
|
|
|
|
Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use 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.
|
|
|
|
## Use query variables
|
|
|
|
Variables of the type _Query_ help you query Loki for lists of labels or label values.
|
|
The Loki data source provides a form to select the type of values expected for a given variable.
|
|
|
|
The form has these options:
|
|
|
|
| Query type | Example label | Example stream selector | List returned |
|
|
| ------------ | ------------- | ----------------------- | ---------------------------------------------------------------- |
|
|
| Label names | Not required | Not required | Label names. |
|
|
| Label values | `label` | | Label values for `label`. |
|
|
| Label values | `label` | `log stream selector` | Label values for `label` in the specified `log stream selector`. |
|
|
|
|
## Use ad hoc filters
|
|
|
|
Loki supports the special **Ad hoc filters** variable type.
|
|
You can use this variable type to specify any number of key/value filters, and Grafana applies them automatically to all of your Loki queries.
|
|
|
|
For more information, refer to [Add ad hoc filters]({{< relref "../../../dashboards/variables/add-template-variables#add-ad-hoc-filters" >}}).
|
|
|
|
## Use interval and range variables
|
|
|
|
You can use some global built-in variables in query variables: `$__interval`, `$__interval_ms`, `$__range`, `$__range_s`, and `$__range_ms`.
|
|
|
|
For more information, refer to [Global built-in variables]({{< relref "../../../dashboards/variables/add-template-variables#global-variables" >}}).
|