Different ways to match on alert name

24 views
Skip to first unread message

Brian Gottfried

unread,
Oct 26, 2020, 3:42:56 PM10/26/20
to Prometheus Users
Hello! I'm looking to forward specific alerts via the Webhook config and can't find the best way to specify the specific alerts I want to match. For the moment, the # of alerts is small enough that I can specify a route for each alert individually
e.g.
routes:
  - receiver: 'dest'
    match:
      alertname: A
  - receiver: 'dest'
    match:
      alertname: B
...

But I'm assuming there's a better way to do so? Can you add multiple alerts in the alertname field, separated by commas or some other divider? I think I saw a "match_re" field that would let you do it via regex? And more generally, is there something in the Alertmanager configuration documentation that specifies these options that I missed?

Brian Candler

unread,
Oct 27, 2020, 9:31:04 AM10/27/20
to Prometheus Users
On Monday, 26 October 2020 19:42:56 UTC, Brian Gottfried wrote:
Hello! I'm looking to forward specific alerts via the Webhook config and can't find the best way to specify the specific alerts I want to match. For the moment, the # of alerts is small enough that I can specify a route for each alert individually
e.g.
routes:
  - receiver: 'dest'
    match:
      alertname: A
  - receiver: 'dest'
    match:
      alertname: B
...

But I'm assuming there's a better way to do so? Can you add multiple alerts in the alertname field, separated by commas or some other divider? I think I saw a "match_re" field that would let you do it via regex?

Yes.

    match:
      alertname: A
      severity: critical

will mean that *both* those labels must have the values given..

    match_re:
      alertname: 'A|B'
      severity: 'critical|warning'

will match alertname "A" or "B", *and* at the same time must have severity "critical" or "warning". And

    match_re:
      alertname: 'A|B'
    match:
      severity: critical

will match alerts where the alertname is "A" or "B", and the severity is "critical".

 
And more generally, is there something in the Alertmanager configuration documentation that specifies these options that I missed?

The bit which shows match and match_re is under "route":
 
Reply all
Reply to author
Forward
0 new messages