如何在警报管理器路由匹配中写入not条件?只有当严重性不是严重时,我才想执行此条件。
routes
- match_re:
severity: ^(?!critical)
receiver: teams-channel-webhook-high-priority我尝试了上面的正则表达式条件.But它不起作用。
我还试着用
not_match_re: severity: critical
即使这样也不管用。
发布于 2020-07-10 07:00:57
答:您可以创建一个嵌套的路由树,这实际上为您提供了“If...Then...Else...”能力。
routes:
- ... something to do always
continue: true
- match:
severity: critical
routes:
- ... things to do when critical
- ...
- ... things to do when not critical
- ...完全省略“匹配”条件会使规则始终匹配。
请注意,"continue: true“在匹配后继续执行下一条规则,但仅在同一级别上。如果没有匹配,它将仅跳转到父规则集。
当然,您也可以显式匹配所有非关键严重性,例如match_re: severity:'debug|informational|warning‘
发布于 2021-07-18 21:59:15
match和match_re已在route中弃用,转而使用matcher
matchers接受一系列条件( and )并支持正则表达式match =~和NOT match !~运算符。
route:
# root route
routes:
- receiver: recvA
matchers:
- severity!~"^critical$"
- receiver: recvB
# route:receiverB with no matchers will always match if the previous routes don'thttps://stackoverflow.com/questions/61490846
复制相似问题