alertmanager/template/default.tmpl

222 lines
6.6 KiB
Cheetah

{{ define "__alertmanager" }}AlertManager{{ end }}
{{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}{{ end }}
{{ define "__subject" }}{{$dot := .}}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts | firing | len }}{{ end }}] {{ range .GroupLabels | sortedPairs }}{{ .Value }} {{ end }}{{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ range .CommonLabels | sortedPairs }}{{ if eq "" (index $dot.GroupLabels .Name) }}{{ .Value }} {{ end }}{{ end }}){{ end }}{{ end }}
{{ define "__description" }}{{ end }}
{{ define "__text_alert_list" }}{{ range . }}Labels:
{{ range .Labels | sortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}Annotations:
{{ range .Annotations | sortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end}}
{{ end }}{{ end }}
{{ define "slack.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "slack.default.fallback" }}{{ template "__subject" . }}{{ end }}
{{ define "slack.default.pretext" }}{{ end }}
{{ define "slack.default.titlelink" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "slack.default.text" }}{{ template "__subject" . }}{{ end }}
{{ define "pagerduty.default.description" }}{{ template "__subject" . }}{{ end }}
{{ define "pagerduty.default.client" }}{{ template "__alertmanager" . }}{{ end }}
{{ define "pagerduty.default.clientURL" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "pagerduty.default.instances" }}{{ template "__text_alert_list" . }}{{ end }}
{{ define "opsgenie.default.description" }}{{ template "__subject" . }}{{ end }}
{{ define "opsgenie.default.source" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "email.default.subject" }}{{ template "__subject" . }}{{ end }}
{{ define "email.default.html" }}
{{/*
The following is the readable HTML code for the mail template. It has to be inlined, e.g. by
http://templates.mailchimp.com/resources/inline-css/.
The inlined output is inserted after this comment.
----
<style>
table {
border-spacing: 0;
border-collapse: collapse;
}
table.outer {
margin: 0 auto;
width: 100%;
max-width: 700px;
background: #fff;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #202020 !important;
}
td {
padding: 0;
text-align: left;
vertical-align: top;
}
.inner {
padding: 10px;
}
h1 {
font-size: 1.15em;
font-weight: bold;
margin-bottom: 18px;
}
li .labelname, li .labelvalue {
color: inherit;
white-space: pre-wrap;
display: inline-block;
}
li .labelname {
padding-right: 15px;
font-weight: bold;
font-family: monospace;
}
li .labelvalue {
font-size: 0.9em;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
.column {
width: 100%;
height: 100%;
display: inline-block;
vertical-align: top;
}
.alert {
border: 1px dotted #959595;
}
.labels.column {
max-width: 295px;
color: #fff !important;
background: #4f4f4f;
}
.annotations.column {
max-width: 395px;
}
</style>
<table class="outer" align="center">
<tr>
<td>
<table width="100%">
<tr>
<td class="inner">
<h1>{{ len .Alerts }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for {{ .GroupLabels }}</h1>
</td>
</tr>
</table>
</td>
{{ range .Alerts }}
<tr>
<td class="alert">
<div class="labels column">
<table width="100%">
<tr>
<td class="inner">
<ul>
{{ range $label, $value := .Labels }}
<li>
<span class="labelname">{{ $label }}</span>
<span class="labelvalue">{{ $value }}</span>
</li>
{{ end }}
</ul>
</td>
</tr>
</table>
</div>
<div class="annotations column">
<table width="100%">
<tr>
<td class="inner">
<ul>
{{ range $label, $value := .Annotations }}
<li>
<span class="labelname">{{ $label }}</span>
<span class="labelvalue">{{ $value }}</span>
</li>
{{ end }}
</ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
{{ end }}
</table>
---
Template end, the following is the inlined version of the above.
*/}}
<table class="outer" align="center" style="border-spacing: 0;border-collapse: collapse;margin: 0 auto;width: 100%;max-width: 700px;background: #fff;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;color: #202020;">
<tr>
<td style="padding: 0;text-align: left;vertical-align: top;">
<table width="100%" style="border-spacing: 0;border-collapse: collapse;">
<tr>
<td class="inner" style="padding: 10px;text-align: left;vertical-align: top;">
<h1 style="font-size: 1.15em;font-weight: bold;margin-bottom: 18px;">{{ len .Alerts }} alert{{ if gt (len .Alerts) 1 }}s{{ end }} for {{ .GroupLabels }}</h1>
</td>
</tr>
</table>
</td>
{{ range .Alerts }}
</tr><tr>
<td class="alert" style="padding: 0;text-align: left;vertical-align: top;border: 1px dotted #959595;">
<div class="labels column" style="width: 100%;height: 100%;display: inline-block;vertical-align: top;max-width: 295px;color: #fff;background: #4f4f4f;">
<table width="100%" style="border-spacing: 0;border-collapse: collapse;">
<tr>
<td class="inner" style="padding: 10px;text-align: left;vertical-align: top;">
<ul style="list-style: none;margin: 0;padding: 0;">
{{ range $label, $value := .Labels }}
<li>
<span class="labelname" style="color: inherit;white-space: pre-wrap;display: inline-block;padding-right: 15px;font-weight: bold;font-family: monospace;">{{ $label }}</span>
<span class="labelvalue" style="color: inherit;white-space: pre-wrap;display: inline-block;font-size: 0.9em;">{{ $value }}</span>
</li>
{{ end }}
</ul>
</td>
</tr>
</table>
</div>
<div class="annotations column" style="width: 100%;height: 100%;display: inline-block;vertical-align: top;max-width: 395px;">
<table width="100%" style="border-spacing: 0;border-collapse: collapse;">
<tr>
<td class="inner" style="padding: 10px;text-align: left;vertical-align: top;">
<ul style="list-style: none;margin: 0;padding: 0;">
{{ range $label, $value := .Annotations }}
<li>
<span class="labelname" style="color: inherit;white-space: pre-wrap;display: inline-block;padding-right: 15px;font-weight: bold;font-family: monospace;">{{ $label }}</span>
<span class="labelvalue" style="color: inherit;white-space: pre-wrap;display: inline-block;font-size: 0.9em;">{{ $value }}</span>
</li>
{{ end }}
</ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
{{ end }}
</table>
{{ end }}