自用的报警模板
{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}{{if eq $v.status "resolved"}}**[Prometheus恢复信息]({{$v.generatorURL}})** *[{{$v.labels.alertname}}]({{$var}})* 告警级别:{{$v.labels.severity}} 告警状态:{{$v.status}} 开始时间:{{GetCSTtime $v.startsAt}} 结束时间:{{GetCSTtime $v.endsAt}} {{if eq $v.labels.alertname "pod restart" }} POD名称:{{$v.labels.pod}} {{end}} {{if eq $v.labels.alertname "mem-used" }}故障原因:{{$v.annotations.summary}} 所属节点:{{$v.labels.node}} {{$v.labels.host_ip}} 故障详情:{{$v.annotations.message}}{{else}}{{if eq $v.labels.workspace "livedata" }}故障服务:{{$v.labels.workload}} {{$v.annotations.summary}} 故障详情:{{$v.annotations.message}}{{else}}{{if eq $v.labels.rule_group "kubernetes-resources"}}故障原因:{{$v.annotations.summary}} 故障详情:{{$v.annotations.description}}{{else}}故障原因:{{$v.annotations.summary}} 故障详情:{{$v.annotations.message}} {{end}}{{end}}{{end}} {{else}}**[Prometheus告警信息]({{$v.generatorURL}})** *[{{$v.labels.alertname}}]({{$var}})* 告警级别:{{$v.labels.severity}} 告警状态:{{$v.status}} 开始时间:{{GetCSTtime $v.startsAt}} {{if eq $v.labels.workspace "livedata" }}故障服务:{{$v.labels.workload}} {{$v.annotations.summary}} 故障详情:{{$v.annotations.message}}{{else}}{{if eq $v.labels.rule_group "kubernetes-resources"}}故障原因:{{$v.annotations.summary}} 故障详情:{{$v.annotations.description}}{{else}}故障原因:{{$v.annotations.summary}}{{end}}{{end}} {{if eq $v.labels.alertname "mem-used" }}所属节点:{{$v.labels.node}} {{$v.labels.host_ip}} 故障详情:{{$v.annotations.message}}{{end}}{{if eq $v.labels.alertname "pod restart" }}POD名称:{{$v.labels.pod}} 故障详情:{{$v.annotations.message}}{{end}} {{end}} {{end}}
标签:end,labels,summary,故障,自用,告警,eq,annotations,模板 From: https://www.cnblogs.com/putaoo/p/17815307.html