8
match:
  [ <labelname>: <labelvalue>, ... ]

# A set of regex-matchers an alert has to fulfill to match the node.
match_re:
  [ <labelname>: <regex>, ... ]

My question is what is the difference between a match and a match_re statement? I have used both of the within prometheus and the effect they have is the same.

Any help is very much appreciated!!

zemmer W
  • 139
  • 1
  • 2
  • 7

3 Answers3

9

With "match_re" you can use regular expression like in the following examples:

service: "mysql|postgre"

system: ".*_(foo|boo)$"

recipient: "(.*,)?customer/sms(,.*)?"

alertname: "watchdog.*alert"
7

From the v0.22.2 both match and match_re are deprecated in favor of matchers. A nice new feature is the possibility to define negative matchers.

# DEPRECATED: Use matchers below.
# A set of equality matchers an alert has to fulfill to match the node.
match:
  [ <labelname>: <labelvalue>, ... ]

# DEPRECATED: Use matchers below.
# A set of regex-matchers an alert has to fulfill to match the node.
match_re:
  [ <labelname>: <regex>, ... ]
  
# A list of matchers that an alert has to fulfill to match the node. 
matchers:
  [ - <matcher> ... ]

Source

Kattia
  • 303
  • 4
  • 13
4

Use matchers instead of them:

  routes:
  - receiver: 'database-pager'
    group_wait: 10s
    matchers:
    - service=~"mysql|cassandra"
  - receiver: 'frontend-pager'
    group_by: [product, environment]
    matchers:
    - team="frontend"

In newer versions match and match_re are deprecated in favor of matchers.

Milad Jahandideh
  • 490
  • 1
  • 4
  • 13
  • `matchers` was introduced in v 0.22. If the reader is using something older than that, they'll still need to use `match` & `match_re`. – Dale C. Anderson Aug 29 '22 at 17:31