prometheus-webhook-dingtalk 最新版安装( 告警方式集成配置文件)

prometheus-webhook-dingtalk, version 1.4.0 安装记录

prometheus 是对alertmanager 告警的一个扩展,支持钉钉,微信,邮件告警和自建告警模板
最新版将告警方式的添加集成到配置文件中,方便添加与修改
下面就讲一下安装最新版本prometheus-webhookdingtalk 安装与踩到的坑

1.获取 prometheus-webhook-dingtalk 安装包

git clone https://github.com/timonwong/prometheus-webhook-dingtalk.git

2.解决依赖

(1)yarn
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
yum install yarn
(2)go 环境依赖
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
tar zxf go1.14.2.linux-amd64.tar.gz -C /usr/local/
echo "export PATH=$PATH:/usr/local/go/bin" >>~/.bashrc
source ~/.bashrc
(3)node.js 版本

node.js 要求版本大于等于8

wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz
下载node.js 新版本
tar xf node-v12.16.1-linux-x64.tar.xz -C /usr/local/
mv /usr/bin/node /usr/bin/node_bakv6.17.1
ln -s /usr/local/node-v12.16.1-linux-x64/bin/node /usr/bin/node

3.进行编译安装

cd prometheus-webhook-dingtalk.git
make build

等待即可

4.配置 & 启动

启动项

 ./prometheus-webhook-dingtalk --help
usage: prometheus-webhook-dingtalk [<flags>]

Flags:
  -h, --help                  Show context-sensitive help (also try --help-long and --help-man).
      --web.listen-address=":8060"  
                              The address to listen on for web interface.
      --web.enable-ui         Enable Web UI mounted on /ui path
      --web.enable-lifecycle  Enable reload via HTTP request.
      --config.file="config.yml"  
                              Path to the configuration file.
      --log.level=info        Only log messages with the given severity or above. One of: [debug, info, warn, error]
      --log.format=logfmt     Output format of log messages. One of: [logfmt, json]
      --version               Show application version.

配置文件

## Request timeout
# timeout: 5s

## Customizable templates path
此处进行告警模板的指定,不要时使用 --template.file= 进行指定,否则会报错,只会识别tempaltefile 而不去识别指定dingdingwebhook的 配置文件
# templates:       
#   - contrib/templates/legacy/template.tmpl

## You can also override default template using `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, previously was known as "profiles"
targets:
  webhook1:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
    # secret for signature
    secret: SEC000000000000000000000
  webhook2:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
  webhook_legacy:
    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
    # Customize template content
    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
    mention:
      mobiles: ['156xxxx8827', '189xxxx8325']

踩坑备注

进行告警模板的指定时,不要按照老版本通过 --template.file= 进行指定,会报错,
只会识别tempaltefile 而不去识别指定dingdingwebhook的 配置文件

新版本将 tempaltefile 指定集成到了 配置文件中,只需要在配置文件中指定template file 的位置就行了

你可能感兴趣的:(prometheus-webhook-dingtalk 最新版安装( 告警方式集成配置文件))