【问题标题】:Alertmanager Match vs Match_reAlertmanager Match vs Match_re
【发布时间】:2020-04-24 09:14:02
【问题描述】:
match:
  [ <labelname>: <labelvalue>, ... ]

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

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

非常感谢任何帮助!

【问题讨论】:

    标签: prometheus-alertmanager


    【解决方案1】:

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

    service: "mysql|postgre"
    
    system: ".*_(foo|boo)$"
    
    recipient: "(.*,)?customer/sms(,.*)?"
    
    alertname: "watchdog.*alert"
    

    【讨论】:

    • 我们可以同时使用matchmatch_re 作为接收器吗?
    • 是的,你可以使用它。
    【解决方案2】:

    v0.22.2 开始,matchmatch_re 都已弃用,而代之以 matchers。一个不错的新功能是可以定义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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-06
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2021-07-13
      • 2021-12-17
      相关资源
      最近更新 更多