Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt
Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/grafana/v9.0/alerting/fundamentals/annotation-label/labels-and-label-matchers.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/grafana/v9.0/alerting/fundamentals/annotation-label/labels-and-label-matchers/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
How label matching works
Use labels and label matchers to link alert rules to notification policies and silences. This allows for a very flexible way to manage your alert instances, specify which policy should handle them, and which alerts to silence.
A label matchers consists of 3 distinct parts, the label, the value and the operator.
The Label field is the name of the label to match. It must exactly match the label name.
The Value field matches against the corresponding value for the specified Label name. How it matches depends on the Operator value.
The Operator field is the operator to match against the label value. The available operators are:
| Operator | Description |
|---|---|
= | Select labels that are exactly equal to the value. |
!= | Select labels that are not equal to the value. |
=~ | Select labels that regex-match the value. |
!~ | Select labels that do not regex-match the value. |
Example of a label matcher
Imagine we’ve defined the following set of labels for our alert.
{ foo=bar, baz=qux, id=12 }
In this situation,
- A label matcher defined as
foo=barwill match this alert rule. - A label matcher defined as
foo!=barwill 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.