Alertmanager Match 与 Match_re

zem*_*r W 8 prometheus-alertmanager

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

# A set of regex-matchers an alert has to fulfill to match the node.
match_re:
  [ <labelname>: <regex>, ... ]
Run Code Online (Sandbox Code Playgroud)

我的问题是 match 和 match_re 语句有什么区别?prometheus里面的两个我都用过,效果是一样的。

很感谢任何形式的帮助!!

Mar*_*ira 9

通过“match_re”,您可以使用正则表达式,如下例所示:

service: "mysql|postgre"

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

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

alertname: "watchdog.*alert"
Run Code Online (Sandbox Code Playgroud)


Kat*_*tia 7

v0.22.2两者中的match和match_re均已被弃用,取而代之的是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> ... ]
Run Code Online (Sandbox Code Playgroud)

来源


Mil*_*deh 5

使用matchers而不是它们:

  routes:
  - receiver: 'database-pager'
    group_wait: 10s
    matchers:
    - service=~"mysql|cassandra"
  - receiver: 'frontend-pager'
    group_by: [product, environment]
    matchers:
    - team="frontend"
Run Code Online (Sandbox Code Playgroud)

在较新的版本中match, 和match_re已被弃用,取而代之的是匹配器。