Search code examples
prometheusprometheus-alertmanager

Prometheus Alert.rules; How to filter by multiple jobs?


I have an Alert configured like so:

ALERT ServiceDown
IF up{job!="ABC"} == 0
FOR 2m...

What I would like to do, is to add another job to filter out, like "XYZ", so something like this (which is not grammatically correct):

ALERT ServiceDown
IF up{job!="ABC" AND job!="XYZ"} == 0
FOR 2m...

It should be straightforward but I couldn't find any examples on prometheus.io or anywhere else.

Any suggestions? Thanks!


Solution

  • Try using the regular expression matching, in your case you want to find all time series that do NOT match job==ABC and job==XYZ.
    The !~ label matching operator which will select labels that do not regex-match the provided string:

    ALERT ServiceDown
    IF up{job!~"ABC|XYZ"} == 0
    FOR 2m...