Prometheus 釘釘自定義告警模板實現

配置釘釘告警

配置釘釘告警請參閱:  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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章