K8S学习之基础四十:K8S配置altermanager发送告警到钉钉群
配置altermanager发送告警到钉钉群
创建钉钉群,设置机器人助手(必须是管理员才能设置),获取webhook
webhook:
https://oapi.dingtalk.com/robot/send?access_token=25bed933a52d69f192347b5be4b2193bc0b257a6d9ae68d81619e3ae3d93f7c6
# 创建cm,配置钉钉群信息
vi alertmanager-cm-dintalk.yaml
kind: ConfigMap
apiVersion: v1
metadata:name: alertmanagernamespace: monitor-sa
data:alertmanager.yml: |-global:resolve_timeout: 1msmtp_smarthost: 'smtp.163.com:25'smtp_from: '18937120061@163.com'smtp_auth_username: '18937120061@163.com'smtp_auth_password: '*' # 163邮箱smtp_require_tls: falseroute:group_by: [alertname]group_wait: 10sgroup_interval: 10srepeat_interval: 10mreceiver: cluster1 # 对应接收名称receivers:- name: cluster1 # 接收名称webhook_configs:- url: 'http://172.16.80.131:8060/dingtalk/cluster1/send' # 程序所在服务器路径send_resolved: true
# 启动程序,替换access_token为上面的webhook
nohup ./prometheus-webhook-dingtalk --web.listen-address="0.0.0.0:8060" --ding.profile="cluster1=https://oapi.dingtalk.com/robot/send?access_token=25bed933a52d69f192347b5be4b2193bc0b257a6d9ae68d81619e3ae3d93f7c6" &
钉钉群能正常收到告警