我正在尝试通过 Prometheus 设置 Alertmanager。我已经编写了警报规则和 alertmanager.yaml 文件。我可以通过 alertmanager 向 slack 发送警报。
问题
我无法美化我的警报。我想用我的警报发送描述、警报名称、摘要。
我尝试使用 CommonAnnotations 来发送我的警报的描述、名称和摘要。但不幸的是,它只适用于“DeadMansSwitch”。对于所有其他警报,我无法在 slack 频道上看到任何内容。
#PrometheusRules
- alert: esWorkerACKSPM
annotations:
description: Buzzsaw esworkers acknowledgment per minute.
summary: Prometheus' alert notification :- Buzzsaw average esworker acknowledgment per minute is lower than 10.
expr: avg(bz_ackspm{broker=~"ldbb-.*", group="esworkers"}) < 10
for: 5m
labels:
severity: urgent
#alertmanager.yaml
global:
templates:
- 'https://github.com/prometheus/alertmanager/blob/master/template/default.tmpl'
route:
group_by: ['severity']
group_wait: 3s
group_interval: 5s
repeat_interval: 20s
receiver: mail-receiver
routes:
- match:
severity: urgent
receiver: critical-mail-receiver
routes:
receivers:
- name: 'mail-receiver'
slack_configs:
- api_url: https://hooks.slack.com/services/XXXXXX/XXXXX1/e7AXXXXXXopzmHNTJmL
channel: '#alertmanager-testing'
text: '{{ .CommonAnnotations.summary }}'
- name: 'critical-mail-receiver'
slack_configs:
- api_url: https://hooks.slack.com/services/T0XXXXCL/XXX6G4/VUVKZ8CnXXXXXXXzZguoXq
channel: '#place'
text: '{{ .CommonAnnotations.summary }} '
预期结果:- 松弛通道上的警报摘要。
实际结果:- 只能在 slack 上看到 DeadMansSwitch(警报)的摘要。对于其他警报,它只是显示
[FIRING:2] urgent (monitoring/kube-prometheus-prometheus-prometheus)