Prometheus-prometheus-webhook-dingtalk 安装

简介: Prometheus-prometheus-webhook-dingtalk 安装

prometheus-webhook-dingtalk 安装

1、编译安装
------------------------  安装 go 环境 ---------------------------
yum -y install go
# 在GOPATH下新建目录
cd /srv

-------------------------  安装钉钉插件  -----------------------------
git clone  https://github.com/timonwong/prometheus-webhook-dingtalk.git

------------------------ 安装nodejs -------------------------------
wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz
tar xf node-v12.16.1-linux-x64.tar.xz -C /usr/local/
cd /usr/local  && mv node-v12.16.1-linux-x64 nodejs
vim /etc/profile.d/nodejs.sh 
​
export NODE_HOME=/usr/local/nodejs
export PATH=$PATH:$NODE_HOME/bin
source /etc/profile

--------------------------   安装yarn环境 ---------------------------
cd /srv/prometheus-webhook-dingtalk
make build

--------------------------  启动配置 -------------------------------
mkdir /data/dingtalk
cp config.example.yml /data/dingtalk/config.yml
ln -s /root/go/src/github.com/timonwong/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk /usr/local/bin/

2、二进制模拟安装调试
https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v1.4.0/prometheus-webhook-dingtalk-1.4.0.linux-amd64.tar.gz

# 下载并安装
wget https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v0.3.0/prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz
tar -zxf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz -C /opt/
mv /opt/prometheus-webhook-dingtalk-0.3.0.linux-amd64 /opt/prometheus-webhook-dingtalk

----------------------------------- 单文件模式
vim /etc/systemd/system/prometheus-webhook-dingtalk.service
#添加如下内容
[Unit]
Description=prometheus-webhook-dingtalk
After=network-online.target

[Service]
Restart=on-failure
ExecStart=/opt/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk --ding.profile=ops_dingding=自己钉钉机器人的Webhook地址

[Install]
WantedBy=multi-user.target


#命令行启动
systemctl daemon-reload
systemctl start prometheus-webhook-dingtalk
ss -tnl | grep 8060

#测试
curl   -H "Content-Type: application/json"  -d '{ "version": "4", "status": "firing", "description":"description_content"}'  http://localhost:8060/dingtalk/ops_dingding/send
---------------------------------------------------------- 配置文件模式
[root@SVR-Prometheus01 prometheus-webhook-dingtalk]# cat dingtalk-webhook.yml 
## Request timeout
timeout: 5s
## Customizable templates path
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: 
    # 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']

-----------------------------------
---------------------------  配置告警
cat /opt/alertmanager/alertmanager.yml
global:
  resolve_timeout: 1m

route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'ops_dingding'
  routes:
  - match:
      team: node
receivers:
- name: 'ops_dingding'
  webhook_configs:
  - url: 'http://x.x.x.x:8060/dingtalk/ops_dingding/send'
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']


-----------------------------------
cat /opt/prometheus/rules/node_down.yml 
groups:
- name: Node_Down
  rules:
  - alert: Node实例宕机
    expr: up == 0
    for: 10s
    labels:
      user: prometheus
      severity: Warning
    annotations:
      summary: "{{ $labels.instance }} 服务宕机"
      description: "{{ $labels.instance }} of job {{ $labels.job }} has been Down."
修改Prometheus配置文件
cat /opt/prometheus/prometheus.yml
# 修改以下内容
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets: ["x.x.x.x:9093"]
rule_files:
   - ./rules/*.yml

#重启
systemctl restart prometheus

111.png
222.png

相关文章
|
3月前
|
Prometheus 监控 Kubernetes
Prometheus + Grafana安装
Prometheus + Grafana安装
|
3月前
|
Prometheus Cloud Native Java
微服务框架(二十三)Prometheus + Grafana 安装、配置及使用
此系列文章将会描述Java框架Spring Boot、服务治理框架Dubbo、应用容器引擎Docker,及使用Spring Boot集成Dubbo、Mybatis等开源框架,其中穿插着Spring Boot中日志切面等技术的实现,然后通过gitlab-CI以持续集成为Docker镜像。 本文为Prometheus + Grafana 安装、配置及使用 本系列文章中所使用的框架版本为Spring ...
|
9天前
|
Prometheus 监控 Cloud Native
Prometheus 安装与配置
Prometheus 安装与配置
|
5月前
|
Prometheus Cloud Native
Mac下安装 Prometheus+Grafana
Mac下安装 Prometheus+Grafana
149 0
|
3月前
|
Prometheus Kubernetes Cloud Native
kubernetes安装Prometheus
##### 安装 在目标集群上,执行如下命令: ```shell kubectl apply -f https://github.com/512team/dhorse/raw/main/conf/kubernetes-prometheus.yml
|
3月前
|
Prometheus Cloud Native Linux
Linux下安装prometheus & grafana
Linux下安装prometheus & grafana
81 0
|
4月前
|
Prometheus Cloud Native 数据安全/隐私保护
Prometheus实战篇:docker安装Prometheus
Docker搭建Prometheus监控系统
|
4月前
|
Prometheus Cloud Native Unix
prometheus|云原生|kubernetes内部安装prometheus
prometheus|云原生|kubernetes内部安装prometheus
60 0
|
4月前
|
Prometheus Cloud Native 关系型数据库
prometheus|云原生|prometheus项目安装postgres-exporter监视组件的部署简介
prometheus|云原生|prometheus项目安装postgres-exporter监视组件的部署简介
83 0
|
7月前
|
Prometheus Kubernetes 监控
Kubernetes(k8s)上安装Prometheus和Grafana监控(下)
Kubernetes(k8s)上安装Prometheus和Grafana监控(下)
288 0