Prometheus配置钉钉告警
Prometheus配置钉钉告警获取钉钉token配置钉钉webhook? ??????钉钉通过机器人提供了一个webhook接口,但是呢钉钉机器人对文件格式有严格要求,所以必须通过特定的格式转换,才能发送给你钉钉的机器人。有人已经写了转换插件,我是个拿来主义者(主要是自己不会搞,先跑起来再说),那就直接用吧。命令行方式
安装go语言wget -c https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gztar -C /usr/local/ -zxvf go1.8.3.linux-amd64.tar.gz mkdir -p /home/gocodecat << EOF >> /etc/profileexport GOROOT=/usr/local/go #设置为go安装的路径export GOPATH=/home/gocode ?#默认安装包的路径export PATH=$PATH:$GOROOT/bin:$GOPATH/binEOFsource ?/etc/profile编译钉钉插件cd /home/gocode/mkdir -p src/github.com/timonwong/cd /home/gocode/src/github.com/timonwong/git clone ?https://github.com/timonwong/prometheus-webhook-dingtalk.gitmakeln -s ?/home/gocode/src/github.com/timonwong/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk /usr/local/bin/prometheus-webhook-dingtalk启动插件nohup prometheus-webhook-dingtalk --ding.profile="webhook1=send" &编译alertmanager配置文件global: ?resolve_timeout: 5m ?smtp_smarthost: 'smtp.qiye.aliyun.com:465' ?smtp_from: '[email protected]' ?smtp_auth_username: '[email protected]' ?smtp_auth_password: 'xxx' ?smtp_require_tls: falseroute: ?group_by: ?group_wait: 10s ?group_interval: 10s ?repeat_interval: 1h ?receiver: 'web.hook'receivers:- name: 'web.hook' ?email_configs: ?- to: '[email protected]' ?webhook_configs: ?- url: 'http://localhost:8060/dingtalk/webhook1/send' ???send_resolved: false结果截图
遇到问题说明1.如果编译出错,可能是go版本问题。2. 原始代码go编译好像写死了目录,如果出错,可以按照我写的去做。(具体不得而知,go语言不熟)docker方式
直接执行docker程序docker run -d --restart always -p 8060:8060 timonwong/prometheus-webhook-dingtalk:master --ding.profile="webhook1=send run -d --restart always -p 8060:8060 timonwong/prometheus-webhook-dingtalk:v0.3.0 --ding.profile="webhook1=send src="https://cache.yisu.com/upload/information/20200309/33/61148.jpg" alt="Prometheus配置钉钉告警">
遇到说明1.不知道我报警设置的有问题,还是程序有问题,钉钉发一次就报错了还需要继续改进。参考文档将钉钉接入 Prometheus AlertManager WebHook
配置钉钉告警
docker镜像
二进制程序文件
通过webhook推送钉钉
cetnos7 安装go环境
页:
[1]