我在GitHub的開發者的幫助下找到了一個解決方案。
您可能會看到配置的處理方式如下,if語句類似於與AND和OR聲明。
Alertmanager將配置應用於上下左右原則。上下類似於您將在常規if語句中使用的OR語句。
當你從左側將右側,你可以用AND語句中,如果命令進行比較。
而且你應該記住,第一條語句相匹配的時候,並沒有「與」部分中聲明,alertmanager推動警報接收器,無需進一步尋找其他任何比賽。因此,在上面的示例中,如果prometheus使用以下標籤觸發警報{嚴重程度:「警告」,應用程序:「barfoo」},則將警報發送到hipchat-teamX。
注意以下,應用的標籤值hipchat-teamY的路由匹配。那麼爲什麼它不被髮送到那條路線呢?答案並不是diffucult,這是因爲第一個匹配,並且沒有聲明子路由,所以它將停止查找任何其他匹配。但是,如果alertmanager具有如下面代碼的配置,則警報將被髮送到接收者'hipchat-teamY'。
routes:
match:
severity:"warning"
receiver: "hipchat-teamX"
routes:
match_re:
application:"(barfoo.*)"
receiver: "hipchat-teamY"
match_re:
application:"(foo|bar)"
receiver: "hipchat-teamX"
match_re:
application:"(barfoo.*)"
receiver: "hipchat-teamY"
爲了使它有點更先進,asume普羅米修斯發送一個新的警報以下標籤{嚴重性:「關鍵」,應用「barfoo」}。通過以下配置,警報將被髮送到hipchat-teamX。
並與標籤{嚴重性: 「關鍵」,應用 「富」},將警報發送到hipchat-teamY。
routes:
match:
severity:"warning"
receiver: "hipchat-teamX"
routes:
match_re:
application:"(barfoo.*)"
receiver: "hipchat-teamY"
match_re:
application:"(foo|bar)"
receiver: "hipchat-teamX"
match:
severity:"critical"
receiver: "hipchat-teamY"
routes:
match_re:
application:"(barfoo.*)"
receiver: "hipchat-teamX"
match_re:
application:"(foo|bar)"
receiver: "hipchat-teamY"
我希望這個解釋能夠幫助其他遇到同樣問題或問題的人。