[v11.3.x] Alerting docs: clarify $labels and query labels (#97356)
Alerting docs: clarify `$labels` and query labels (#97350)
* Alerting docs: clarify `$labels` and query labels
* fix mispell
(cherry picked from commit 8fe36e1c83)
Co-authored-by: Pepe Cano <825430+ppcano@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
54ff80afb1
commit
8bc94106e2
@@ -16,6 +16,11 @@ title: Annotation and label template reference
|
||||
menuTitle: Template reference
|
||||
weight: 101
|
||||
refs:
|
||||
label-types:
|
||||
- pattern: /docs/grafana/
|
||||
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/alert-rules/annotation-label/#label-types
|
||||
- pattern: /docs/grafana-cloud/
|
||||
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/annotation-label/#label-types
|
||||
notification-template-reference:
|
||||
- pattern: /docs/grafana/
|
||||
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/configure-notifications/template-notifications/reference/
|
||||
@@ -72,15 +77,15 @@ The following variables are available when templating annotations and labels:
|
||||
|
||||
| Variables | Description |
|
||||
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [$labels](#labels) | Contains all labels from the query. |
|
||||
| [$labels](#labels) | Contains all labels from the query, only query labels. |
|
||||
| [$values](#values) | Contains the labels and floating point values of all instant queries and expressions, indexed by their Ref IDs. |
|
||||
| [$value](#value) | A string containing the labels and values of all instant queries; threshold, reduce and math expressions, and classic conditions in the alert rule. |
|
||||
|
||||
### $labels
|
||||
|
||||
The `$labels` variable contains all labels from the query.
|
||||
The `$labels` variable contains all labels from the query. It excludes [user-configured and reserved labels](ref:label-types), containing only query labels.
|
||||
|
||||
{{< figure src="/media/docs/alerting/query-labels-and_value.png" max-width="1200px" caption="An alert rule displaying labels and value from a query" >}}
|
||||
{{< figure src="/media/docs/alerting/query-labels-and-values.png" max-width="1200px" caption="An alert rule displaying labels and value from a query." >}}
|
||||
|
||||
For example, suppose you have a query that returns CPU usage for all of your servers, and you have an alert rule that fires when any of your servers have exceeded 80% CPU usage for the last 5 minutes. You want to add a summary annotation to the alert that tells you which server is experiencing high CPU usage. With the `$labels` variable you can write a template that prints a human-readable sentence such as:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user