Prometheus配置釘釘告警

Prometheus配置釘釘告警

獲取釘釘token


圖片.png

圖片.png

 

docker部署prometheus-webhook-dingtalk


prometheus-webhook-dingtalk地址:

https://github.com/timonwong/prometheus-webhook-dingtalk


釘釘token如下:

https://oapi.dingtalk.com/robot/send?access_token=XXXXXX

 

執行docker安裝prometheus-webhook-dingtalk指令

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容器運行情況

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


 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章