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 定义的。

相关推荐
四方云1 天前
Kamailio + Prometheus 集成方案(含完整可执行配置)
prometheus
雨辰AI2 天前
SpringBoot3 + 人大金仓 V9 微服务监控实战|Prometheus+Grafana+SkyWalking 全链路监控
数据库·后端·微服务·grafana·prometheus·skywalking
rKWP8gKv73 天前
Java微服务性能监控:Prometheus与Grafana集成方案
java·微服务·prometheus
2601_958320574 天前
【小白零基础上手 】钉钉内部机器人接入 OpenClaw 完整流程讲解(含安装包)
人工智能·windows·机器人·钉钉·open claw·open claw安装
江南风月4 天前
WGCLOUD如果使用SQL Server数据库推荐哪个版本
运维·网络·zabbix·运维开发·prometheus
AI木马人5 天前
8.人工智能实战:大模型服务“看起来正常却突然变慢”?Prometheus + Grafana + GPU 指标构建全链路监控体系
人工智能·grafana·prometheus
无心水5 天前
【Hermes:多平台接入】19、钉钉/飞书/企业微信:国内办公场景接入指南 —— 将 Honcho 智能体部署到你的工作聊天软件
人工智能·钉钉·飞书·企业微信·openclaw·hermes·honcho
invicinble5 天前
关于搭建运维监控系统(Prometheus+Grafana)
运维·grafana·prometheus
云中计算巫作坤5 天前
泛微OA,该不该扔?
钉钉·飞书·企业数字化·泛微oa
翼龙云_cloud7 天前
阿里云代理商:阿里云部署的Hermes Agent 钉钉接入指南
人工智能·阿里云·云计算·钉钉·ai 智能体·hermes agent