Search code examples
prometheusmetricsprometheus-alertmanager

route matching multiple labels


I am not getting alertmanager to send alerts based on multiple labels.

In general sending e-mails on alerts is working. But only if there is a simple match on one label. E.g. teamB route is working. teamA route is not.

route:
  receiver: default-receiver
  routes:
  - receiver: teamA
    match:
      environment: production
    match_re:
      job: ^(?:app2| app3)$
  - receiver: teamB
    match:
      application: app1
      environment: production
receivers:
- name: default-receiver 
- name: teamA
- name: teamB

The syntax seems correct as there is no error message on loading alertmanager:

019-07-24T08:03:59.242791707Z level=info ts=2019-07-24T08:03:59.242607527Z caller=main.go:334 msg="Loading configuration file" file=/etc/alertmanager/config.yml

What's wrong with the teamA route?

I am using https://prometheus.io/webtools/alerting/routing-tree-editor/ to analyze the issue. The code above can simply be copied over to that editor to visualize the results of given label sets.


Solution

  • {environment="production", job="app2"} goes to teamA as I'd expect, I suspect the issue is the leading space before app3.