To clarify, here's how it would work with a single receiver which delivers
to both slack and pagerduty:
route:
receiver: 'slack-notifications'
routes:
- matchers:
- 'severity =~ "critical|warning"'
* receiver: slack-and-pagerduty*
Whereas if you want a single rule to deliver to multiple receivers, you
need a nested set of routes (each of which has no matchers, so they always
trigger):
route:
receiver: 'slack-notifications'
routes:
- matchers:
- 'severity =~ "critical|warning"'
* routes:*
* - receiver: slack-notifications continue: true*
* - receiver: pagerduty-notifications*
You can turn this into a one-liner [untested]:
route:
receiver: 'slack-notifications'
routes:
- matchers:
- 'severity =~ "critical|warning"'
* routes: [ {receiver: slack-notifications, continue: true},
{receiver: pagerduty-notifications} ]*
On Friday, 31 December 2021 at 10:24:53 UTC Brian Candler wrote:
> - match:
> severity: critical,warning
>
> This matches only a label with name "severity" and value exactly equal to
> "critical,warning", e.g. it would match
>
> myalert{severity="critical,warning"} 1
>
> You need to use either the new matchers
> <https://prometheus.io/docs/alerting/latest/configuration/#matcher> or
> the older and deprecated match_re
> <https://prometheus.io/docs/alerting/latest/configuration/#route> to
> match multiple values of the same label.
>
> However, you will make your life easier if you create a single receiver
> which sends to both slack and pagerduty:
>
> receivers:
> - name: 'slack-and-pagerduty'
> slack_configs:
> - ...
> pagerduty_configs:
> - ...
>
> This can end up being a bit messy, because if you also need other
> receivers for *only* slack or *only* pagerduty then you'll end up
> duplicating some of these configs. But once you start doing selective
> routing, you'll find your actual routing rules get way more complicated if
> you have to duplicate those, with correct nested routes and "continue"
> statements to send one alert to multiple receivers. (It would be nice if
> alertmanager allowed multiple receivers for a single rule, but
> unfortunately it doesn't)
>
> One other thing I'll mention: your final "continue: false" does nothing.
> Firstly because it defaults to false, but secondly even "continue: true" on
> the last rule in a list of routes has no effect. It only means "after
> successful match, continue onto the next routing rule", and if there are no
> more, it doesn't do anything. The default "receiver" which exists outside
> all of the routing rules is only triggered if *none* of the rules match,
> regardless of whether continue is set.
>
> HTH,
>
> Brian.
>
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/9aa4dd33-dbb6-4bc5-8e83-806b14edbf2fn%40googlegroups.com.