我正在使用文本文件收集器导出到统计.prom文件,每分钟更新一次-统计.sh脚本。下面是一个.prom文件的例子。
item_has_stock{id="item.aaa", store="x"} 1
item_has_stock{id="item.aaa", store="y"} 1
item_has_stock{id="item.bbb", store="z"} 1
item_has_stock{id="item.ccc", store="k"} 1
item_has_stock{id="item.aaa", store="x"} 1
item_has_stock{id="item.aaa", store="y"} 0
item_has_stock{id="item.bbb", store="z"} 0
item_has_stock{id="item.ccc", store="k"} 0
Alertmanager,发送以下警报:
[FIRING:3] Item Stock
Item item.aaa at store y
Item item.bbb at store z
Item item.ccc at store k
item_has_stock{id="item.aaa", store="x"} 1
item_has_stock{id="item.aaa", store="y"} 1
item_has_stock{id="item.bbb", store="z"} 0
item_has_stock{id="item.ccc", store="k"} 0
现在,alertmanager发送的警报如下所示:
[FIRING:2] Item Stock
Item item.aaa at store y
Item item.bbb at store z
Item item.ccc at store k
发射计数正确地减少了,但是行“Item项目.aaa“在y店”不应该再展示了。。。以下是alertmanager配置:
route:
receiver: 'default'
routes:
- receiver: 'item-stock'
group_by: ['item_has_stock']
group_wait: 45s
group_interval: 1m
repeat_interval: 2m
match_re:
id: .*item.*
receivers:
- name: 'default'
slack_configs:
- send_resolved: true
api_url: '...'
channel: '#channel'
username: 'alertmanager'
- name: 'item-stock'
slack_configs:
- send_resolved: true
api_url: '...'
channel: '#channel'
username: 'alertmanager'
title: '[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] Item Stock'
text: "{{ range .Alerts }}\nItem {{ .Labels.id }} at store {{ .Labels.store }}{{ end }}"
每3分钟触发一次触发的下一次触发警报(组间隔+重复间隔),与上面的示例相同。仅在15分钟后(即5次警报后),行“项目项目.aaa“在y店”终于消失了。另外,我希望这条线路的警报得到解决。。。