在 Prometheus 中使用钉钉机器人

启动 prometheus-webhook-dingtalk

  • /data/prometheus-webhook-dingtalk/config/config.yml
1
2
3
4
5
6
7
8
9
10
11
12
timeout: 10s

default_message:
title: '{{ template "legacy.title" . }}'
text: '{{ template "legacy.content" . }}'

targets:
webhook1:
url: https://oapi.dingtalk.com/robot/send?access_token=xxx
secret: yyy
mention:
all: true
1
2
3
4
5
6
docker run -d \
--name prometheus-webhook-dingtalk \
--restart always \
-p 8060:8060 \
-v /data/prometheus-webhook-dingtalk/config:/etc/prometheus-webhook-dingtalk \
timonwong/prometheus-webhook-dingtalk

修改 prometheus 配置文件

1
2
3
4
5
6
7
8
route:
receiver: "dingtalk1"

receivers:
- name: dingtalk1
webhook_configs:
- send_resolved: true
url: http://127.0.0.1:8060/dingtalk/webhook1/send

参考

  • theo.im/blog

  • timonwong/prometheus-webhook-dingtalk