配置钉钉告警
配置钉钉告警请参阅: https://blog.csdn.net/knight_zhou/article/details/105583741
实现钉钉的模板配置:
我们先来看看二进制包的命令行参数:
$/opt/prometheus/server/ding/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk -h
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.
模板配置文件如下(以下贴出关键参数配置):
## 前面的内容省略
{{ define "ding.link.content" }}
{{ if gt (len .Alerts.Firing) 0 -}}
告警列表:
-----------
{{ template "__text_alert_list" .Alerts.Firing }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
恢复列表:
{{ template "__text_resolve_list" .Alerts.Resolved }}
{{- end }}
{{- end }}
看看最终效果图
详细配置说明请参阅视频教程:
第6章第10节: Prometheus 钉钉自定义告警模板实现
视频教程地址: https://edu.csdn.net/course/play/27740
来源:oschina
链接:https://my.oschina.net/u/4276629/blog/4320775