Alertmanager配置钉钉告警
原创
©著作权归作者所有:来自51CTO博客作者You0tech的原创作品,请联系作者获取转载授权,否则将追究法律责任
先创建钉钉群聊
添加群机器人
https://oapi.dingtalk.com/robot/send?access_token=b713c27c658c4bbc798392d5ce76cc1408c9c0517b0146f75278e5c845a90031
启动钉钉告警插件
[root@k8smaster1 altermanager]# tar -zxvf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz
[root@k8smaster1 prometheus-webhook-dingtalk-0.3.0.linux-amd64]# nohup ./prometheus-webhook-dingtalk --web.listen-address="0.0.0.0:8060" --ding.profile="k8s=https://oapi.dingtalk.com/robot/send?access_token=b713c27c658c4bbc798392d5ce76cc1408c9c0517b0146f75278e5c845a90031" &
创建alertmanager configMap 配置文件
kind: ConfigMap
apiVersion: v1
metadata:
name: alertmanager
namespace: monitor-sa
data:
alertmanager.yml: |-
global:
resolve_timeout: 1m
smtp_smarthost: 'smtp.126.com:25'
smtp_from: 'fanhuaruxu@126.com'
smtp_auth_username: 'fanhuaruxu@126.com'
smtp_auth_password: 'YDINTNORLQYACWQZ'
smtp_require_tls: false
route:
group_by: [alertname]
group_wait: 10s
group_interval: 10s
repeat_interval: 10m
receiver: k8s
receivers:
- name: k8s
webhook_configs:
- url: 'http://192.168.1.170:8060/dingtalk/k8s/send'
send_resolved: true
查看告警信息
[root@k8smaster1 altermanager]# kubectl logs pod prometheus-server-f9bb6686-zrcxc -c alertmanager -n monitor-sa