{{- define "wework.zhg.message" -}} {{- if gt (len .Alerts.Firing) 0 -}} =====异常告警===== {{- range $index, $alert := .Alerts.Firing -}} 告警类型: {{ $alert.Labels.alertname }} 告警阈值: {{ $alert.Labels.size }} 故障时间: {{ ($alert.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }} {{- if gt (len $alert.Labels.instance) 0 -}} 实例信息: {{ $alert.Labels.instance }} {{- end -}} {{- if gt (len $alert.Annotations) 0 -}} Annotations: {{- range $key, $value := $alert.Annotations -}} {{$key}}: {{$value}} {{- end -}} {{- end -}} {{- end -}} =====END===== {{- end -}} {{- if gt (len .Alerts.Resolved) 0 -}} {{- range $index, $alert := .Alerts.Resolved -}} ====异常恢复==== 告警类型: {{ $alert.Labels.alertname }} 告警阈值: {{ $alert.Labels.size }} 故障时间: {{ ($alert.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }} 恢复时间: {{ ($alert.EndsAt.Add 28800e9).Format "2006-01-02 15:04:05" }} {{- if gt (len $alert.Labels.instance) 0 -}} 实例信息: {{ $alert.Labels.instance }} {{- end -}} {{- end -}} =====END===== {{- end -}} {{- end -}}

告警消息模板 - 异常告警和恢复通知

原文地址: https://www.cveoy.top/t/topic/mSmM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录