介绍

在此部分简要介绍 Prometheus Webhook DingTalk 的作用和使用 Docker 部署的优势。概述将要涵盖的常用参数以及如何配置 Docker 容器的关键概念。

步骤 1: 获取 Prometheus Webhook DingTalk 代码

解释如何获取 Prometheus Webhook DingTalk 的代码并进入存储库目录。

git clone https://github.com/timonwong/prometheus-webhook-dingtalk.git
cd prometheus-webhook-dingtalk
  • 1.
  • 2.
步骤 2: 配置 Webhook

指导读者如何在 config.yml 文件中配置 DingTalk 的 Webhook URL,并介绍可配置的其他常用参数。

global:
  resolve_timeout: 5m
  webhook_urls:
    - 'https://oapi.dingtalk.com/robot/send?access_token=YOUR_ACCESS_TOKEN'
    # 其他可选参数示例
    # timeout: 10s
    # max_alerts: 100
    # ignore_namespace: true
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

这配置对接Alertmanager时使用

targets:
  webhook1:
    url: https://oapi.dingtalk.com/robot/send?access_token=YOUR_ACCESS_TOKEN
  • 1.
  • 2.
  • 3.
步骤 3: 使用 Docker 构建和运行

直接拉官方镜像使用,注意配置更新为自己的

docker pull timonwong/prometheus-webhook-dingtalk:latest
  • 1.

展示如何使用 Docker 构建和运行 Prometheus Webhook DingTalk 容器,并解释如何添加常用的 Docker 参数。

docker build -t prometheus-webhook-dingtalk .
docker run -d -p 8060:8060 --restart=always --name=prometheus-webhook prometheus-webhook-dingtalk
  • 1.
  • 2.
步骤 4: 配置 Prometheus或Alertmanager

指导读者在 Prometheus 的配置文件中添加常用的配置参数,确保 Prometheus 能够正确连接到部署的 Webhook。

alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - 'localhost:8060/alert'
    # 其他可选参数示例
    # timeout: 30s
    # api_version: v2
    # cluster: my-cluster
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

也指导读者在 Alertmanager的配置文件中添加常用的配置参数,确保 Alertmanager能够正确连接到部署的 Webhook。

global:
  resolve_timeout: 5m
route:
  receiver: webhook
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 5m
  group_by: [alertname]
  routes:
  - receiver: webhook
    group_wait: 10s
receivers:
- name: webhook
  webhook_configs:
  - url: http://YOUR_DINGTALK_ADDRESS/dingtalk/webhook1/send  
    send_resolved: true
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
步骤 5: 测试

鼓励读者测试配置是否正常工作。提供简单的测试步骤或示例以确保 Prometheus 能够将警报发送到 DingTalk。

总结

总结文章的内容,并强调使用 Docker 部署 Prometheus Webhook DingTalk 时常用参数的重要性。