Prometheus配置钉钉告警
node
获取钉钉tokengit
docker部署prometheus-webhook-dingtalkgithub
prometheus-webhook-dingtalk地址:web
https://github.com/timonwong/prometheus-webhook-dingtalk
docker
钉钉token以下:api
https://oapi.dingtalk.com/robot/send?access_token=XXXXXXbash
执行docker安装prometheus-webhook-dingtalk指令tcp
docker run -d --restart always -p 8060:8060 timonwong/prometheus-webhook-dingtalk:v0.3.0 --ding.profile="webhook1=https://oapi.dingtalk.com/robot/send?access_token=XXXXXX"
查看prometheus-webhook-dingtalk容器运行状况ide
root@test03:/usr/local/alertmanager# docker ps|grep prometheus-webhook-dingtalk 34dcac5e1baf timonwong/prometheus-webhook-dingtalk:v0.3.0 "/bin/prometheus-web…" 16 hours ago Up 16 hours 0.0.0.0:8060->8060/tcp clever_varahamihira
配置alertmanager文件测试
root@test03:/usr/local/alertmanager# cat alertmanager.yml global: resolve_timeout: 5m route: receiver: webhook group_wait: 30s group_interval: 1m repeat_interval: 4h group_by: [alertname] routes: - receiver: webhook group_wait: 10s receivers: - name: webhook webhook_configs: - url: http://localhost:8060/dingtalk/webhook1/send send_resolved: true
注意:http://localhost:8060/dingtalk/webhook1/send ,其中webhook1,必定是当时使用docker运行prometheus-webhook-dingtalk容器指定钉钉接口参数的变量:webhook1,以下:webhook1
--ding.profile="webhook1=https://oapi.dingtalk.com/robot/send?access_token=XXXXXX"
中止node_exporter.service测试钉钉告警
root@test02:~# systemctl stop node_exporter.service
InstanceDown处于PENDING状态,则等待发送告警,期间是等待告警规则持续一分钟up状态都等于0,才会触发告警
InstanceDown处于FIRING状态,则发送告警给接收者
查看钉钉告警信息
恢复node_exporter.service
root@test02:~# systemctl start node_exporter.service
查看钉钉恢复信息