版本3.1.1
@wanjunlei 麻烦大佬解答一下
实现目标:自定义钉钉tmpl模板,发送报警到钉钉群,钉钉关键词是alert,操作如下:
vim alertmanager.yml
“global”:
“resolve_timeout”: “5m”
“templates”:
- “/etc/alertmanager/config/test.tmpl”
“inhibit_rules”:
- “equal”:
“source_match”:
"severity": "critical"
“target_match_re”:
"severity": "warning|info"
- “equal”:
“source_match”:
"severity": "warning"
“target_match_re”:
"severity": "info"
“receivers”:
- “name”: “Default”
- “name”: “Watchdog”
- “name”: “prometheus”
“webhook_configs”:
- “name”: “event”
“webhook_configs”:
- “name”: “auditing”
“webhook_configs”:
“route”:
“group_by”:
“namespace”
“alertname”
“rule_id”
“group_interval”: “5m”
“group_wait”: “30s”
“receiver”: “Default”
“repeat_interval”: “12h”
“routes”:
“match”:
“alertname”: “Watchdog”
“receiver”: “Watchdog”
“group_interval”: “30s”
“match”:
“alerttype”: “event”
“receiver”: “event”
“group_interval”: “30s”
“match”:
“alerttype”: “auditing”
“receiver”: “auditing”
“match_re”:
“alerttype”: “.*”
“receiver”: “prometheus”
vim test.tmpl
{{ define “default.message” }}
{{ range .Alerts }}
========start==========
触发时间: {{ .StartsAt.Format “2006-01-02 15:04:05” }}
告警程序: prometheus_alert
告警级别: {{ .Labels.severity }}
告警类型: {{ .Labels.alertname }}
故障主机: {{ .Labels.instance }}
告警主题: {{ .Annotations.summary }}
告警详情: {{ .Annotations.description }}
========end==========
{{ end }}
{{ end }}
kubectl delete secret alertmanager-main -n kubesphere-monitoring-system
kubectl create secret generic alertmanager-main –from-file=alertmanager.yaml –from-file=test.tmpl -n kubesphere-monitoring-system
钉钉报警还是老模板的格式,哪里配错了?