Search code examples
prometheus-operatorprometheus-alertmanager

Alertmanager only goes through default receiver


As stated in the title, I have an issue with alertmanager from prometheus-operator. I'm trying to filter some alerts using routes but it doesn't seem to be taken into account.

When I use the default receiver everything seems to be working fine but if I try to filter with a default receiver that does nothing and then a route, it doesn't goes in the route and I don't get any error.

The secret I'm using:

    route:
      group_wait: 30s
      group_interval: 5m
      repeat_interval: 4h
      group_by: [cluster]
      receiver: 'default'
      routes:
      - match:
          alertname: !Watchdog
        receiver: 'slack-devops'
        continue: true
    templates: ['/etc/alertmanager/config/*.tmpl']
    receivers:
    - name: 'default'
    - name: 'slack-devops'
      slack_configs:
      - channel: "tmp-test-srv-alerting"

With this configuration it puts everything in the default route and neither goes in the routes, I don't even get an error. Would someone has an idea on how to make this work?


Solution

  • Try using 'matchers' instead of 'match' which supports negative matching: Instead of

    # ❌ This is invalid
    route:
    - match:
       alertname: !WatchDog
    
    # ✅ This is correct
    route:
    - matchers:
       - alertname!=Watchdog
    

    Docs: https://prometheus.io/docs/alerting/latest/configuration/#matcher