Jenkins添加钉钉机器人推送

本文指导如何在Prometheus中配置alertmanager,通过wget下载并安装DingTalkwebhook插件,编辑启动脚本和alertmanager配置,最终使用supervisor守护进程实现告警自动发送到钉钉群组。
摘要由CSDN通过智能技术生成
1 添加钉钉机器人,获取webhook
参考 https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1
2 下载插件(二进制文件)
$ wget https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v0.3.0/prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz
3 解压并move至/usr/local/prometheus目录下
$ tar zxvf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz
$ mv prometheus-webhook-dingtalk-0.3.0.linux-amd64/prometheus-webhook-dingtalk /usr/local/prometheus/alertmanager
4 编辑启动脚本(请替换为自己的webhook URL 及 ding.profile)
$ cat dingding_start.sh
nohup /usr/local/prometheus/alertmanager/prometheus-webhook-dingtalk --ding.profile="ops_dingding=https://oapi.dingtalk.com/robot/send?access_token=XXXXXXX"  2>&1 1>/usr/local/prometheus/alertmanager/dingding.log &
$ sh dingding_start.sh
5 编辑alertmanager.yml,增加web_hook配置并重启alertmanager
  - name: 'ops_dingding'
    webhook_configs:
    - url: 'http://127.0.0.1:8060/dingtalk/dingtalk_u/send'
      send_resolved: true
6.supervisor守护
[program:dingtalk]
command=/opt/soft/monitor/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk --ding.profile='dingtalk_u=https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx' --ding.timeout=5s --log.level=info
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs=1                    ; number of processes copies to start (def 1)
directory=/opt/soft/monitor/prometheus-webhook-dingtalk
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
autostart=true                ; start at supervisord start (default: true)
autorestart=unexpected        ; whether/when to restart (default: unexpected)
startsecs=1                   ; number of secs prog must stay running (def. 1)
startretries=3                ; max # of serial start failures (default 3)
exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT               ; signal used to kill process (default TERM)
stopwaitsecs=3               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
user=prometheus
redirect_stderr=true          ; redirect proc stderr to stdout (default false)
stdout_logfile=/var/log/supervisor/dingtalk.log        ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=10MB   ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=3     ; # of stdout logfile backups (default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A="1",B="2"       ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值