Files
grafana/docs/sources/alerting/fundamentals/annotation-label/labels-and-label-matchers.md
Christopher Moyer a568d421f8 Docs: Setup refactor (#49739)
* builds out refactored setup topics

* Automatically fix some relrefs with mv-manager

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Use refs for tutorials content which is outside of this repository

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Manually fix complicated relrefs

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* consolidates team sync and db encryption topics

* Fix relrefs

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* updates setup index file

* Convert TOML to YAML

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Add current alias for new alerting content

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Add current aliases to new setup-grafana and configure-security pages

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>

* moves saml docs, updates order in TOC

* Manually fix relrefs

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* added usage insights topics, adjusted weights

* corrected relrefs

* Fix relrefs broken in rebase

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-06-02 11:57:22 -05:00

1.8 KiB

aliases description keywords title weight
/docs/grafana/latest/alerting/fundamentals/annotation-label/labels-and-label-matchers/
Learn about labels and label matchers in alerting
grafana
alerting
guide
fundamentals
Label matchers 117

How label matching works

Use labels and label matchers to link alert rules to [notification policies]({{< relref "../../notifications/" >}}) and [silences]({{< relref "../../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=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.