我正试图用警报激活我的春季启动应用程序端点,因为prometheus的警报规则中定义的所需事件已损坏,所以我想将我的应用程序端点添加为接收器,以接收来自prometheus-alertmanager的警报。有人能建议如何将端点配置为此receiver
标签的接收器,而不是任何其他推送通知程序吗?
- receiver: 'frontend-pager'
group_by: [product, environment]
matchers:
- team="frontend"
我认为"webhook receiver"可以帮助您。更多信息可以参考文档https://prometheus.io/docs/alerting/latest/configuration/#webhook_config
这是一个基于blackbox_exporter的度量抓取创建的webhook警报示例。
- 普罗米修斯规则设置
您需要创建触发警报的规则,例如在此处定义了一个名为"http_health_alert"的规则。
groups:
- name: http
rules:
- alert: http_health_alert
expr: probe_success == 0
for: 3m
labels:
type: http_health
annotations:
description: Health check for {{$labels.instance}} is down
- 警报管理器设置
'match'设置为http_health_alert,则警报将发送到http://example.com/alert/receiver'通过HTTP/POST方法(我想你会提前准备的(。警报将向配置的终结点发布JSON格式"http://example.com/alert/receiver"。您还可以针对不同的标签内容在端点/程序中自定义不同的接收方法或接收信息。
global:
route:
group_by: [alertname, env]
group_wait: 30s
group_interval: 3m
repeat_interval: 1h
routes:
- match:
alertname: http_health_alert
group_by: [alertname, env]
group_wait: 30s
group_interval: 3m
repeat_interval: 1h
receiver: webhook_receiver
receivers:
- name: webhook_receiver
webhook_configs:
- send_resolved: true
url: http://example.com/alert/receiver
- name: other_receiver
email_configs:
- send_resolved: true
to: xx
from: xxx