Prometheus-prometheus-webhook-dingtalk 安装

本文涉及的产品
可观测监控 Prometheus 版,每月50GB免费额度
简介: 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

相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
相关文章
|
6月前
|
Prometheus 监控 Kubernetes
Prometheus + Grafana安装
Prometheus + Grafana安装
|
6月前
|
Prometheus Cloud Native Java
微服务框架(二十三)Prometheus + Grafana 安装、配置及使用
此系列文章将会描述Java框架Spring Boot、服务治理框架Dubbo、应用容器引擎Docker,及使用Spring Boot集成Dubbo、Mybatis等开源框架,其中穿插着Spring Boot中日志切面等技术的实现,然后通过gitlab-CI以持续集成为Docker镜像。 本文为Prometheus + Grafana 安装、配置及使用 本系列文章中所使用的框架版本为Spring ...
|
22天前
|
Prometheus 监控 Cloud Native
基于Docker安装Grafana和Prometheus
Grafana 是一款用 Go 语言开发的开源数据可视化工具,支持数据监控和统计,并具备告警功能。通过 Docker 部署 Grafana 和 Prometheus,可实现系统数据的采集、展示和告警。默认登录用户名和密码均为 admin。配置 Prometheus 数据源后,可导入主机监控模板(ID 8919)进行数据展示。
59 2
|
3月前
|
Prometheus 监控 Kubernetes
prometheus学习笔记之简介与安装
prometheus学习笔记之简介与安装
prometheus学习笔记之简介与安装
|
2月前
|
Prometheus 监控 Cloud Native
docker安装prometheus+Granfan并监控容器
【9月更文挑战第14天】本文介绍了在Docker中安装Prometheus与Grafana并监控容器的步骤,包括创建配置文件、运行Prometheus与Grafana容器,以及在Grafana中配置数据源和创建监控仪表盘,展示了如何通过Prometheus抓取数据并利用Grafana展示容器的CPU使用率等关键指标。
|
2月前
|
存储 Prometheus 监控
在Ubuntu系统上安装与配置Prometheus的步骤
通过以上步骤,您应该已经成功在Ubuntu系统上安装并配置了Prometheus。您现在可以开始使用Prometheus收集和分析您的系统和应用程序的指标数据了。
179 1
|
3月前
|
Prometheus 监控 Cloud Native
prometheus学习笔记之Grafana安装与配置
prometheus学习笔记之Grafana安装与配置
|
Prometheus Cloud Native
Mac下安装 Prometheus+Grafana
Mac下安装 Prometheus+Grafana
420 0
|
6月前
|
Prometheus 监控 Cloud Native
Prometheus 安装与配置
Prometheus 安装与配置
|
6月前
|
Prometheus Cloud Native 数据安全/隐私保护
Prometheus实战篇:docker安装Prometheus
Docker搭建Prometheus监控系统