Prometheus配置釘釘告警

Prometheus配置釘釘告警
node

獲取釘釘tokengit


圖片.png

圖片.png

 

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,纔會觸發告警

圖片.png


InstanceDown處於FIRING狀態,則發送告警給接收者

圖片.png

 

查看釘釘告警信息

圖片.png

 

恢復node_exporter.service

root@test02:~# systemctl start node_exporter.service


查看釘釘恢復信息

圖片.png

相關文章
相關標籤/搜索