Alertmanager 报警模板
作者:互联网
{{ define "test.html" }}
{{- if gt (len .Alerts.Firing) 0 -}}
@告警
<table border="5">
<tr><td>报警项</td>
<td>实例</td>
<td>报警详情</td>
<td>报警阀值</td>
<td>开始时间</td>
</tr>
{{ range $i, $alert := .Alerts }}
<tr><td>{{ index $alert.Labels "alertname" }}</td>
<td>{{ index $alert.Labels "instance" }}</td>
<td>{{ index $alert.Annotations "description" }}</td>
<td>{{ index $alert.Annotations "value" }}</td>
<td>{{ $alert.StartsAt }}</td>
</tr>
{{ end }}
</table>
{{ end }}
{{- if gt (len .Alerts.Resolved) 0 -}}
@恢复
<table border="5">
<tr><td>报警项</td>
<td>实例</td>
<td>报警详情</td>
<td>报警阀值</td>
<td>开始时间</td>
</tr>
{{ range $i, $alert := .Alerts }}
<tr><td>{{ index $alert.Labels "alertname" }}</td>
<td>{{ index $alert.Labels "instance" }}</td>
<td>{{ index $alert.Annotations "description" }}</td>
<td>{{ index $alert.Annotations "value" }}</td>
<td>{{ $alert.StartsAt }}</td>
</tr>
{{ end }}
</table>
{{ end }}{{- end }}
标签:index,Alertmanager,end,Alerts,报警,alert,Labels,Annotations,模板 来源: https://blog.51cto.com/41889389/2560865