首页 > 其他分享 >【生产】钉钉告警安装 以及调试

【生产】钉钉告警安装 以及调试

时间:2022-12-13 18:32:13浏览次数:71  
标签:end dingtalk Alerts webhook prometheus template 告警 安装 调试

​前提条件Prometheus+Grafana+alertmanager+ 邮件​

钉钉告警安装

下载

去官网下载​​prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz​

wget https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v2.1.0/prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz

上传

mkdir prometheus-webhook-dingtalk && cd prometheus-webhook-dingtalk && rz -be

tar zxvf prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz
mv prometheus-webhook-dingtalk-2.1.0.linux-amd64 /usr/local/
ln -s /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64/ /usr/local/prometheus-webhook-dingtalk

配置config

拷贝个模板文件  

cp config.example.yml config.yml

【生产】钉钉告警安装 以及调试_prometheus-webhook-d

 

url 和 secret 是我们创建告警机器人的 webook 和 "加签"

【生产】钉钉告警安装 以及调试_prometheus-webhook-d_02

【生产】钉钉告警安装 以及调试_prometheus-webhook-d_03

配置模板

[root@zcsmaster1 prometheus-webhook-dingtalk]# pwd
/usr/local/prometheus-webhook-dingtalk
[root@zcsmaster1 prometheus-webhook-dingtalk]# vim contrib/templates/legacy/template.tmpl

contrib/templates/legacy/template.tmpl

{{ define "default.__text_alert_list" }}{{ range . }}
#### \[{{ .Labels.severity | upper }}\] {{ .Annotations.summary }}

**Description:** {{ .Annotations.description }}

**Graph:** [<d83d><dcc8>]({{ .GeneratorURL }})

**Details:**
{{ range .Labels.SortedPairs }}{{ if and (ne (.Name) "severity") (ne (.Name) "summary") }}> - {{ .Name }}: {{ .Value | markdown | html }}
{{ end }}{{ end }}
{{ end }}{{ end }}

{{/* Default */}}
{{ define "default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "default.content" }}#### \[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}\] **[{{ index .GroupLabels "alertname" }}]({{ template "__alertmanagerURL" . }})**
{{ if gt (len .Alerts.Firing) 0 -}}
**Alerts Firing**
{{ template "default.__text_alert_list" .Alerts.Firing }}
{{ range .AtMobiles }}@{{ . }}{{ end }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
**Alerts Resolved**
{{ template "default.__text_alert_list" .Alerts.Resolved }}
{{ range .AtMobiles }}@{{ . }}{{ end }}
{{- end }}
{{- end }}

{{/* Legacy */}}
{{ define "legacy.title" }}{{ template "__subject" . }}{{ end }}
{{ define "legacy.content" }}#### \[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}\] **[{{ index .GroupLabels "alertname" }}]({{ template "__alertmanagerURL" . }})**
{{ template "__text_alert_list" .Alerts.Firing }}
{{- end }}

{{/* Following names for compatibility */}}
{{ define "ding.link.title" }}{{ template "default.title" . }}{{ end }}
{{ define "ding.link.content" }}{{ template "default.content" . }}{{ end }}

配置启动服务

echo '
[Unit]
Description=prometheus-webhook-dingtalk
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk \
--config.file='/usr/local/prometheus-webhook-dingtalk/config.yml'
Restart=on-failure
RestartSec=60s
[Install]
WantedBy=multi-user.target
' > /usr/lib/systemd/system/prometheus-webhook-dingtalk.service

赋权

useradd prometheus
chown prometheus.prometheus /usr/local/prometheus-webhook-dingtalk -R

启动

systemctl enable prometheus-webhook-dingtalk.service
systemctl start prometheus-webhook-dingtalk.service

确认开启了

 ps -aux|grep prometheus-webhook-dingtalk

观察日志

journalctl -u prometheus-webhook-dingtalk.service -f

【生产】钉钉告警安装 以及调试_prometheus-webhook-d_04


测试告警

首先修改altermanger 配置

【生产】钉钉告警安装 以及调试_prometheus-webhook-d_05

重启

kubectl  apply -f alertmanager-cm.yaml
kubectl get pod -n ccse
kubectl delete pod prometheus-server-6d8f4447dd-gfprw -n ccse

查看钉钉

【生产】钉钉告警安装 以及调试_prometheus-webhook-d_06




标签:end,dingtalk,Alerts,webhook,prometheus,template,告警,安装,调试
From: https://blog.51cto.com/zhaochengsheng/5934982

相关文章

  • python3.9 在ubuntu上编译安装失败解决
    https://cloud.tencent.com/developer/article/1740752下载#下载源码包至`opt`目录wget-c-P/opthttps://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz#......
  • Ubuntu20.04系统安装Livox ROS Driver
    1.准备工作 先要确保ROS和Livox-SDK安装成功!安装过程可参考:ROS安装:https://blog.csdn.net/weixin_43994864/article/details/119703293Livox-SDK安装:https://blog.csdn......
  • win102-Windows环境下pycharnpython安装版下载、配置(win10-x64位32g内存)
    win102-Windows环境下pycharnpython安装版下载、配置(win10-x64位32g内存)1、建议首先安装anaconda(注意配置path环境)。  python国内镜像地址:http://npm.taobao.org/mirr......
  • SQLIte的安装及库创建
    1.SQLite官方下载地址:https://www.sqlite.org/download.html,下载完成后,将压缩包解压到同一文件夹下 2.CMD命令符切换到上面文件夹,运行sqlite3,显示SQLite版本即表示安装......
  • SQLyog安装和使用
    百度搜索下载安装链接:https://pan.baidu.com/s/1FSZgtDoMWE5Is9Gu_xpjhg提取码:ABAP下载解压后打开.exe可执行文件  选择自己想要的语言,下一步即可然后打开SQLyog......
  • win101-Windows环境下MYSQL5.7免安装版下载、配置(win10-x64位32g内存)
     win101-Windows环境下MYSQL5.7免安装版下载、配置(win10-x64位32g内存)一、MYSQL免安装版下载二、解压安装三、设置登录、修改密码一、MYSQL免安装版下载1、下载链接......
  • Winform Vs Installer之添加自定义安装流程
    1、简介在Winform安装工具之VsInstaller介绍了VsInstaller的基本使用,可以满足基本需求,但是开发中遇到一些需要自定义安装流程的需求,如何通过VsInstaller来完成......
  • Linux上安装MySQL超详细
    Linux上安装MySQL第一步:确保服务器在最新的状态(可有可无)[root@chenstudy~]#yum-yupdate第二步:检测系统是否自带安装MySQL我之前安装过MySQL,现在已经卸载了[roo......
  • 树莓派安装psutil失败报错
    安装pip3installpsutilroot@ubuntu:/home/ubuntu#pip3installpsutil报错信息WARNING:Retrying(Retry(total=4,connect=None,read=None,redirect=None,status......
  • Winforms Cefsharp应用通过Vs Installer安装,应用崩溃,缺少文件错误
         本文主要分析winformscefsharp应用通过VsInstaller做成安装包后,安装程序后,启动程序导致应用崩溃,提示System.IO.FileNotFoundException应用程序:Win......