From 3a864b7b2736904753ae7fb1a8da43196b575263 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 28 Sep 2022 04:19:08 -0400 Subject: [PATCH] Documentation: clarify label matching (#55650) (#55890) * Documentation: clarify label matching Behaviour in case of multiple matchers is not documented, but my experiments show they are reduced using logical AND. Please validate the updated description. * Accept wording suggestion Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Accept suggestion for docs/sources/alerting/fundamentals/annotation-label/labels-and-label-matchers.md Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> * Improve wording according to review suggestions Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com> (cherry picked from commit efef672d1971648b18374a9ab0f9eeffe8f0607e) Co-authored-by: Vladimir --- .../labels-and-label-matchers.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/sources/alerting/fundamentals/annotation-label/labels-and-label-matchers.md b/docs/sources/alerting/fundamentals/annotation-label/labels-and-label-matchers.md index 53f79c4ac61..4376537d0b0 100644 --- a/docs/sources/alerting/fundamentals/annotation-label/labels-and-label-matchers.md +++ b/docs/sources/alerting/fundamentals/annotation-label/labels-and-label-matchers.md @@ -30,15 +30,18 @@ A label matchers consists of 3 distinct parts, the **label**, the **value** and | `=~` | Select labels that regex-match the value. | | `!~` | Select labels that do not regex-match the value. | -## Example of a label matcher +If you are using multiple label matchers, they are combined using the AND logical operator. This means that all matchers must match in order to link a rule to a policy. -Imagine we've defined the following set of labels for our alert. +## Example scenario + +If you define the following set of labels for your alert: `{ foo=bar, baz=qux, id=12 }` -In this situation, +then: -- A label matcher defined as `foo=bar` will match this alert rule. -- A label matcher defined as `foo!=bar` will _not_ match this alert rule. -- A label matcher defined as `id=~[0-9]+` will match this alert rule. -- A label matcher defined as `baz!~[0-9]+` will match this alert rule. +- A label matcher defined as `foo=bar` matches this alert rule. +- A label matcher defined as `foo!=bar` does _not_ match this alert rule. +- A label matcher defined as `id=~[0-9]+` matches this alert rule. +- A label matcher defined as `baz!~[0-9]+` matches this alert rule. +- Two label matchers defined as `foo=bar` and `id=~[0-9]+` match this alert rule.