-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault-message-workflow-card.tmpl
More file actions
92 lines (90 loc) · 3.3 KB
/
Copy pathdefault-message-workflow-card.tmpl
File metadata and controls
92 lines (90 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{{ define "teams.card" }}
{{- $cardHeadingLineColor := "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAECAAAAABqswrmAAAAEElEQVR42mJogEBAAAAA//8ICAIBsBUbsAAAAABJRU5ErkJggg==" }}
{{- $headingColor := "" }}
{{- if eq .Status "resolved" -}}
{{- $cardHeadingLineColor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAECAIAAADAusJtAAAAEklEQVR42mLQPa6LjAEBAAD//yQwBIUSNPBIAAAAAElFTkSuQmCC" -}}
{{- $headingColor := "Good" }}
{{- else if eq .Status "firing" -}}
{{- if eq .CommonLabels.severity "critical" -}}
{{- $cardHeadingLineColor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAECAIAAADAusJtAAAAEklEQVR42mLokZJCxoAAAAD//xnYAwEPSWrRAAAAAElFTkSuQmCC" }}
{{- $headingColor := "Attention" }}
{{- else if eq .CommonLabels.severity "warning" -}}
{{- $cardHeadingLineColor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAECAIAAADAusJtAAAAEklEQVR42mL4v5QBGQMCAAD//ziMBpHr7M3UAAAAAElFTkSuQmCC" }}
{{- $headingColor := "warning" }}
{{- end -}}
{{- end -}}
{
"type":"message",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"contentUrl":null,
"content":{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"backgroundImage": {
"url": "{{- $cardHeadingLineColor -}}",
"fillMode": "RepeatHorizontally"
},
"msteams": {
"width": "Full"
},
"body": [
{
"type": "TextBlock",
"text": "Prometheus Alert ({{ .Status | title }})",
"weight": "Bolder",
"size": "Medium",
"style": "Heading",
"color": "{{- $headingColor -}}"
},
{
"type": "TextBlock",
"text": "{{- if eq .CommonAnnotations.summary "" -}}
{{- if eq .CommonAnnotations.message "" -}}
{{- if eq .CommonLabels.alertname "" -}}
Prometheus Alert
{{- else -}}
{{- .CommonLabels.alertname -}}
{{- end -}}
{{- else -}}
{{- .CommonAnnotations.message -}}
{{- end -}}
{{- else -}}
{{- .CommonAnnotations.summary -}}
{{- end -}}",
"wrap": true
},
{{$externalUrl := .ExternalURL}}
{{- range $index, $alert := .Alerts }}{{- if $index }},{{- end }}
{
"type": "TextBlock",
"text": "[{{ $alert.Annotations.description }}]({{ $externalUrl }})",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{{- range $key, $value := $alert.Annotations }}
{
{{- if ne $key "description" -}}
"title": "{{ $key }}",
"value": "{{ $value }}"
{{- end -}}
},
{{- end -}}
{{$c := counter}}{{ range $key, $value := $alert.Labels }}{{if call $c}},{{ end }}
{
"title": "{{ $key }}",
"value": "{{ $value }}"
}
{{- end }}
]
}
{{- end }}
]
}
}]
}
{{ end }}