环境承上两篇:
prometheus 邮件告警
https://blog.csdn.net/oToyix/article/details/120160633
prometheus process-export进程监控
https://blog.csdn.net/oToyix/article/details/120160633
一、下载钉钉插件、配置、启动
下载
wget -c https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v2.0.0/prometheus-webhook-dingtalk-2.0.0.linux-amd64.tar.gz
tar -xf prometheus-webhook-dingtalk-2.0.0.linux-amd64.tar.gz -C /usr/local/
ln -s prometheus-webhook-dingtalk-2.0.0.linux-amd64 dingtalk
cd dingtalk
mv config.example.yml config.yml
cat config.yml
## Request timeout
# timeout: 5s
## Uncomment following line in order to write template from scratch (be careful!)
#no_builtin_template: true
## Customizable templates path
#templates:
# - contrib/templates/legacy/template.tmpl
## You can also override default template using `default_message`
## The following example to use the 'legacy' template from v0.3.0
#default_message:
# title: '{{ template "legacy.title" . }}'
# text: '{{ template "legacy.content" . }}'
## Targets, previously was known as "profiles"
targets:
webhook1:
url: https://oapi.dingtalk.com/robot/send?access_token=d5bb90d0da8e71277e9dd0ad4423419dbb2317187590e311754a835b8ee8a97cx
# secret for signature
secret: SEC1daa48e41873b31717569fa97547a607153781b4ee4902e8a2e2501463d4b2b7x
webhook2:
url: https://oapi.dingtalk.com/robot/send?access_token=d5bb90d0da8e71277e9dd0ad4423419dbb2317187590e311754a835b8ee8a97cx
webhook_legacy:
url: https://oapi.dingtalk.com/robot/send?access_token=d5bb90d0da8e71277e9dd0ad4423419dbb2317187590e311754a835b8ee8a97cx
# Customize template content
message:
# Use legacy template
title: '{{ template "legacy.title" . }}'
text: '{{ template "legacy.content" . }}'
webhook_mention_all:
url: https://oapi.dingtalk.com/robot/send?access_token=d5bb90d0da8e71277e9dd0ad4423419dbb2317187590e311754a835b8ee8a97cx
mention:
all: true
webhook_mention_users:
url: https://oapi.dingtalk.com/robot/send?access_token=d5bb90d0da8e71277e9dd0ad4423419dbb2317187590e311754a835b8ee8a97cx
mention:
mobiles: ['18667967218', '15672205849']
上面token已做修改,需要填写在钉钉群中设置的机器人信息:
启动:
nohup ./prometheus-webhook-dingtalk &
这里也可以做 systemd服务启动
二、修改alertmanager.yml文件
global:
resolve_timeout: 5m
route:
group_by: ['laertname','severity','namespace']
group_wait: 10s
group_interval: 10s
repeat_interval: 10s
receiver: 'dingding.webhook1'
routes:
- receiver: 'dingding.webhook1'
match:
team: devops
group_wait: 10s
group_interval: 15s
repeat_interval: 3h
- receiver: 'dingding.webhook.all'
match:
team: SRE
group_wait: 10s
group_interval: 15s
repeat_interval: 3h
receivers:
- name: 'dingding.webhook1'
webhook_configs:
- url: 'http://192.168.0.58:8060/dingtalk/webhook1/send'
send_resolved: true
- name: 'dingding.webhook.all'
webhook_configs:
- url: 'http://192.168.0.58:8060/dingtalk/webhook_mention_all/send'
send_resolved: true
三、测试
关闭mysql服务 ,看是否可以收到告警信息
-------------------end