Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple match clauses in alertmanager config?

In the docs, it says that we can add a set of match clauses under match:. It says literally:

A set of equality matchers an alert has to fulfill to match the node.

match:
[ <labelname>: <labelvalue>, ... ]

But it doesn't tell us how to actually provide there multiple matchers. Neither does it tell us if these matchers and ANDed or ORd.

So my two questions are:

  1. How does one properly provide multiple match clauses for a receiver?
  2. Will these match clauses be ANDed or ORd?
like image 285
Sahand Avatar asked Sep 07 '25 04:09

Sahand


2 Answers

  1. How does one properly provide multiple match clauses for a receiver?

I would expect following to work:

match:
  label1: value1
  lavel2: value2
  1. Will these match clauses be ANDed or ORd?

All clauses have to match, i.e. the clauses are ANDed.

like image 140
slauth Avatar answered Sep 09 '25 17:09

slauth


Just confirming that you can add multiple match clauses, which are ANDed. Means all clauses have to match.

Like for example:

routes:
    - matchers:
        - name: severity
          value: warning
        - name: foo
          value: bar
      receiver: slack
      repeatInterval: 24h
    - matchers:
        - name: severity
          value: warning
      receiver: msteams
      repeatInterval: 24h

In the example above, both clauses watch on the same severity but the alert message will only be send to the slack receiver, when also the label foo=bar matches. Otherwise the alert will only be send to the msteams receiver.

like image 31
robenn11 Avatar answered Sep 09 '25 16:09

robenn11