prometheus-altermanager之钉钉webhook

一、下载插件

1 下载钉钉插件 prometheus-webhook-dingtalk

二进制下载地址: https://github.com/timonwong/prometheus-webhook-dingtalk/releases

bash 复制代码
curl -o prometheus-webhook-dingtalk.tgz -L https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v2.1.0/prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz

二、部署

将二进制包解压后,放到合适的位置。

这里放在的 /usr/local/ 下,命名为 prometheus-webhook-dingtalk

bash 复制代码
tar -xf prometheus-webhook-dingtalk.tgz
mv prometheus-webhook-dingtalk-2.1.0.linux-amd64  /usr/local/prometheus-webhook-dingtalk

三、配置 systemd

命令行启动项说明

配置项 含义
--web.listen-address=:8060 程序监听端口,默认 8060
--web.enable-lifecycle 支持通过发送 HTTP 请求,热更新配置文件
--config.file=config.yml 指定配置文件路径
--log.level=info 日志级别 [debug, info, warn, error]
--log.format=logfmt 日志输出格式 [logfmt, json]
--web.enable-ui 可以使用 http://ip:8060/ui 打开测试模版的web界面
--version 输出版本信息

webhook-dingtalk.service

bash 复制代码
[Unit]
Description=The prometheus webhook dingtalk
After=network-online.target
Wants=network-online.target

[Service]
WorkingDirectory=/usr/local/prometheus-webhook-dingtalk
ExecStart=/usr/local/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk --config.file=config.yml --web.enable-lifecycle  --web.enable-ui

KillSignal=SIGQUIT

Restart=always

RestartPreventExitStatus=1 6 SIGABRT

TimeoutStopSec=5
KillMode=process
PrivateTmp=true
LimitNOFILE=1048576
LimitNPROC=1048576

[Install]
WantedBy=multi-user.target

config.yml 是相对于 WorkingDirectory 指定的目录

四、配置文件

在部署包里有个示例文件 config.example.yml

yaml 复制代码
## 请求超时时间
# timeout: 5s

## 为了从头开始编写模板,请取消对以下行的注释
#no_builtin_template: true

## 自定义模版文件路径
#templates:
#  - contrib/templates/legacy/template.tmpl

## 您也可以使用 `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, 以前被称为 "profiles"
targets:
  webhook1:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
    # 钉钉机器人安全设置方式:加签
    secret: SEC000000000000000000000
  webhook2:
    # 这个没有使用 secret 进行安全认证,就需要下钉钉机器人那里设置自定义关键词或者IP地址(段)认证方式。
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
  webhook_legacy:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
    # 自定义的模版内容
    message:
      # Use legacy template
      title: '{{ template "legacy.title" . }}'
      text: '{{ template "legacy.content" . }}'
  webhook_mention_all:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
    # @ 所有人
    mention:
      all: true
  webhook_mention_users:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
    # @ '156xxxx8827' 和 '189xxxx8325'
    mention:
      mobiles: ['156xxxx8827', '189xxxx8325']

secret 是钉钉自定义机器人的加密方式的一种。

具体参考钉钉官方文档

在 alertmanager 中配置

yaml 复制代码
receivers:
  - name: 'web.hook'
    webhook_configs:
      - url: 'http://钉钉插件的IP:端口/dingtalk/webhook1/send'

webhook1 是钉钉插件配置文件中 targets 定义的。

相关推荐
是阿楷啊12 小时前
Java大厂面试场景:音视频场景中的Spring Boot与微服务实战
spring boot·redis·spring cloud·微服务·grafana·prometheus·java面试
xixingzhe21 天前
Prometheus+Grafana监控服务器
grafana·prometheus
牛奶咖啡131 天前
Prometheus+Grafana构建云原生分布式监控系统(十六) _基于Alertmanager的告警机制(一)
云原生·prometheus·prometheus告警整合·prometheus告警配置·prometheus告警规则·prometheus触发告警·告警规则配置实践
zandy10112 天前
AI驱动全球销售商机管理:钉钉DingTalk A1的跨域管理智能解决方案
人工智能·百度·钉钉
feng一样的男子3 天前
阿里云的moltbot机器人使用钉钉的Stream流式接入
阿里云·机器人·钉钉
Honmaple3 天前
OpenClaw 钉钉插件安装指南
服务器·网络·钉钉
码农小卡拉3 天前
Prometheus 监控 SpringBoot 应用完整教程
spring boot·后端·grafana·prometheus
牛奶咖啡133 天前
Prometheus+Grafana构建云原生分布式监控系统(十五)_Prometheus中PromQL使用(二)
云原生·prometheus·集合运算·对查询结果排序·直方图原理·统计掉线的实例·检查节点或指标是否存在
牛奶咖啡134 天前
Prometheus+Grafana构建云原生分布式监控系统(十四)_Prometheus中PromQL使用(一)
云原生·prometheus·promql·计算一个时间范围内的平均值·将相同数据整合查看整体趋势·计算时间范围内的最大最小比率·向量标量的算术运算
牛奶咖啡135 天前
Prometheus+Grafana构建云原生分布式监控系统(十三)_Prometheus数据模型及其PromQL
云原生·prometheus·prometheus数据类型·promql使用场景·promql表达式解析·promql数据类型·监控系统的方法论与指标