1. 程式人生 > 實用技巧 >prometheus中的alertmanage配置檔案詳解

prometheus中的alertmanage配置檔案詳解

alertmanage學習連結:
路由中標籤詳解:
https://yunlzheng.gitbook.io/prometheus-book/parti-prometheus-ji-chu/alert/alert-manager-route
alertmanage的配置檔案示例
https://blog.csdn.net/qq_22227087/article/details/96483009
alertmanage主配置檔案中關鍵字(方法)詳解
https://zhuanlan.zhihu.com/p/74932366

###########################################################
prometheus配置檔案和alert,amage配置檔案詳解

prometheus的主配置檔案中包含rule.yml, rule.yml中的rules只負責定義報警的觸發條件(下面有rule.yml配置檔案的樣例)。觸發以後會將訊息轉發到alertmanage,alertmanage的主配置檔案中根據路由選擇轉發給哪個接收者(下面有alertmanage.yml配置檔案的樣例)



############################################################
rule.yml配置樣例
groups:
- name: test-rule rules: - alert: "tcp連線報警" expr: netdata_ipv4_tcpsock_active_connections_average{dimension="connections",family="tcp"} > 1 for: 1s labels: severity: warning annotations: summary: "服務名:{{$labels.alertname}}" description: "業務500報警: {{ $value }}" value:
"{{ $value }}" - name: test-rule2 rules: - alert: "記憶體報警" expr: 100 - ((node_memory_MemAvailable * 100) / node_memory_MemTotal) > 1 for: 1s labels: severity: test annotations: summary: "服務名:{{$labels.alertname}}" description: "業務500報警: {{ $value }}" value: "{{ $value }}
" ########################################################## global: resolve_timeout: 5m # smtp_smarthost: 使用email開啟服務配置 smtp_smarthost: 'smtp.gmail.com:465' # smtp_from:指定通知報警的郵箱 smtp_from: '[email protected]' # smtp_auth_username:郵箱使用者名稱 smtp_auth_username: '[email protected]' # smtp_auth_password:授權密碼 smtp_auth_password: '8899//zz' # smtp_require_tls:是否啟用tls smtp_require_tls: false templates: - '/data/alertmanager/template/*.tmpl' route: receiver: solomontest #接收人的名字可以自己定義 group_by: ['alertname'] group_wait: 10s #組報警等待時間 group_interval: 10s #組報警間隔時間 repeat_interval: 60s #重複報警間隔時間 routes: - receiver: solomontest group_wait: 10s match_re: #使用match_re方法(使用正則的方式匹配,這裡用match更好) env: test #env是報警資料中的標籤,test是標籤的值 receivers: - name: solomontest email_configs: - to: '[email protected]' html: '{{ template "xx.html" . }}' #指定模板 headers: { Subject: "[WARN] 報警郵件" } - name: 'test' email_configs: - to: '[email protected]' html: '{{ template "xx.html" . }}' headers: { Subject: " {{ 第二路由匹配測試}}" } ########################################################