7.3. 添加 Alertmanager Webhook
您可以向现有 Alertmanager 配置添加新 webhook,以接收有关存储集群运行状况的实时警报。您必须启用传入的 webhook,以允许将消息异步到第三方应用程序中。
例如,如果一个 OSD 在 Red Hat Ceph Storage 集群中停机,您可以将 Alertmanager 配置为在 Google chat 上发送通知。
前提条件
- 正在运行的 Red Hat Ceph Storage 集群启用了监控堆栈组件。
- 在接收第三方应用程序上配置的传入 Webhook。
流程
登录
cephadm
shell:示例
[root@host01 ~]# cephadm shell
将 Alertmanager 配置为使用 Webhook 进行通知:
语法
service_type: alertmanager spec: user_data: default_webhook_urls: - "_URLS_"
default_webhook_urls
是添加到默认接收器webhook_configs
配置中的额外 URL 列表。示例
service_type: alertmanager spec: user_data: webhook_configs: - url: 'http:127.0.0.10:8080'
更新 Alertmanager 配置:
示例
[ceph: root@host01 /]# ceph orch reconfig alertmanager
验证
从 Alertmanager 到 Gchat 的通知示例:
示例
using: https://chat.googleapis.com/v1/spaces/(xx- space identifyer -xx)/messages posting: {'status': 'resolved', 'labels': {'alertname': 'PrometheusTargetMissing', 'instance': 'postgres-exporter.host03.chest response: 200 response: { "name": "spaces/(xx- space identifyer -xx)/messages/3PYDBOsIofE.3PYDBOsIofE", "sender": { "name": "users/114022495153014004089", "displayName": "monitoring", "avatarUrl": "", "email": "", "domainId": "", "type": "BOT", "isAnonymous": false, "caaEnabled": false }, "text": "Prometheus target missing (instance postgres-exporter.cluster.local:9187)\n\nA Prometheus target has disappeared. An e "cards": [], "annotations": [], "thread": { "name": "spaces/(xx- space identifyer -xx)/threads/3PYDBOsIofE" }, "space": { "name": "spaces/(xx- space identifyer -xx)", "type": "ROOM", "singleUserBotDm": false, "threaded": false, "displayName": "_privmon", "legacyGroupChat": false }, "fallbackText": "", "argumentText": "Prometheus target missing (instance postgres-exporter.cluster.local:9187)\n\nA Prometheus target has disappea "attachment": [], "createTime": "2022-06-06T06:17:33.805375Z", "lastUpdateTime": "2022-06-06T06:17:33.805375Z"