From 69402f859b314dfdf37b6535316f7a86b6eac1e3 Mon Sep 17 00:00:00 2001 From: Alfredo <109958902+alfredo-d@users.noreply.github.com> Date: Wed, 3 May 2023 16:43:11 +0800 Subject: [PATCH] Docs: Add callout for variables behavior with classic conditions (#67253) * Add doc on classic condition behaviour with labels * Update docs/sources/alerting/fundamentals/annotation-label/variables-label-annotation.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> --------- Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> --- .../annotation-label/variables-label-annotation.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/sources/alerting/fundamentals/annotation-label/variables-label-annotation.md b/docs/sources/alerting/fundamentals/annotation-label/variables-label-annotation.md index 7044712eb47..8d935e91865 100644 --- a/docs/sources/alerting/fundamentals/annotation-label/variables-label-annotation.md +++ b/docs/sources/alerting/fundamentals/annotation-label/variables-label-annotation.md @@ -122,6 +122,14 @@ If the rule uses Classic Conditions instead of Threshold, Reduce and Math expres The first condition is {{ $values.B0 }}, and the second condition is {{ $values.B1 }} ``` +With classic conditions, labels from the query are not available in `$labels` variable, because single alert instance are generated. Instead, you can retrieve the labels from the `$values` variable. + +``` +{{ range $k, $v := $values }} +The value is {{ $v }} and the labels are {{ $v.Labels }} +{{ end }} +``` + ## Functions The following functions are also available when expanding labels and annotations: