alertmanager/template/default.tmpl

208 lines
6.2 KiB
Cheetah
Raw Normal View History

2015-11-25 14:49:26 +00:00
{{ define "__alertmanager" }}AlertManager{{ end }}
{{ define "__alertmanagerURL" }}{{ .ExternalURL }}{{ end }}
{{ define "__subject" }}{{$dot := .}}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts | firing | len }}{{ end }}] {{ range $i, $p := .GroupLabels | sortedPairs }}{{ $p.Value }} {{ end }}{{if gt (len .CommonLabels) (len .GroupLabels) }}({{ range $i, $p := .CommonLabels | sortedPairs }}{{ if eq "" (index $dot.GroupLabels $p.Name) }}{{ $p.Value }} {{ end }}{{ end }}){{ end }}{{ end }}
{{ define "__description" }}TODO{{ end }}
2015-10-11 11:32:34 +00:00
2015-11-25 14:49:26 +00:00
{{ define "slack.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "slack.default.fallback" }}{{ template "__subject" . }}{{ end }}
{{ define "slack.default.pretext" }}{{ end }}
2015-11-25 14:49:26 +00:00
{{ define "slack.default.titlelink" }}{{ template "__alertmanagerURL" }}/something{{ end }}
{{ define "slack.default.text" }}{{ template "__subject" . }}{{ end }}
2015-10-11 11:32:34 +00:00
{{ define "pagerduty.default.description" }}{{ template "__subject" . }}{{ end }}
2015-11-25 14:49:26 +00:00
{{ define "pagerduty.default.client" }}{{ template "__alertmanager" . }}{{ end }}
{{ define "pagerduty.default.clientURL" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "email.default.subject" }}{{ template "__subject" . }}{{ end }}
2015-10-11 11:32:34 +00:00
2015-11-24 22:29:25 +00:00
{{ define "opsgenie.default.description" }}{{ template "__subject" . }}{{ end }}
2015-10-11 15:09:59 +00:00
{{ define "email.default.html" }}
2015-10-20 07:22:36 +00:00
{{/*
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;
2015-10-20 07:22:36 +00:00
}
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;
2015-10-20 07:22:36 +00:00
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>
2015-10-11 11:32:34 +00:00
{{ range .Alerts }}
2015-10-20 07:22:36 +00:00
<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>
2015-10-20 07:22:36 +00:00
<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>
2015-10-11 11:32:34 +00:00
{{ end }}
2015-10-20 07:22:36 +00:00
</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>
2015-10-20 07:22:36 +00:00
<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 }}