Files
grafana/pkg/tests/api/alerting/test-data/mimir-alertmanager.tmpl
Yuri Tseretyan 1e0aaa29af Alerting: Comprehensive payload for Alertmanager convert API tests (#110485)
* do not remove global config
* create more comprehensive payload for mimir alertmanager testing
2025-09-03 12:11:55 -04:00

48 lines
1.3 KiB
Cheetah

{{ define "alert.title" }}
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}
{{ end }}
{{ define "alert.severity" }}
{{- if eq .Labels.severity "critical" -}}
🔴 CRITICAL
{{- else if eq .Labels.severity "warning" -}}
🟡 WARNING
{{- else if eq .Labels.severity "info" -}}
🔵 INFO
{{- else -}}
⚪️ UNKNOWN
{{- end }}
{{ end }}
{{ define "alert.message" }}
{{ range .Alerts }}
*Alert:* {{ .Annotations.summary }}{{ if .Annotations.description }}
*Description:* {{ .Annotations.description }}{{ end }}
*Severity:* {{ template "alert.severity" . }}
*Status:* {{ .Status }}
*Started:* {{ .StartsAt }}
*Labels:*
{{ range .Labels.SortedPairs }} - {{ .Name }}: {{ .Value }}
{{ end }}
{{ end }}
{{ end }}
{{ define "slack.message" }}
{{ template "alert.title" . }}
{{ template "alert.message" . }}
{{ end }}
{{ define "email.message" }}
<!DOCTYPE html>
<html>
<body>
<h2>{{ template "alert.title" . }}</h2>
<pre>{{ template "alert.message" . }}</pre>
</body>
</html>
{{ end }}
{{ define "default" }}
{{ template "alert.title" . }}
{{ template "alert.message" . }}
{{ end }}