-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification_template.go
158 lines (143 loc) · 7.77 KB
/
notification_template.go
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package deploy
const (
NotificationTmpl = `{{ define "rancher.title" }}
{{ if eq (index .Alerts 0).Labels.alert_type "event"}}
{{ (index .Alerts 0).Labels.event_type}} event of {{(index .Alerts 0).Labels.resource_kind}} occurred
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeHealthy"}}
The kubelet on the node {{ (index .Alerts 0).Labels.node_name}} is not healthy
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeCPU"}}
The CPU usage on the node {{ (index .Alerts 0).Labels.node_name}} is over {{ (index .Alerts 0).Labels.cpu_threshold}}%
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeMemory"}}
The memory usage on the node {{ (index .Alerts 0).Labels.node_name}} is over {{ (index .Alerts 0).Labels.mem_threshold}}%
{{ else if eq (index .Alerts 0).Labels.alert_type "podNotScheduled"}}
The Pod {{ (index .Alerts 0).Labels.pod_name}} is not scheduled
{{ else if eq (index .Alerts 0).Labels.alert_type "podNotRunning"}}
The Pod {{ (index .Alerts 0).Labels.pod_name}} is not running
{{ else if eq (index .Alerts 0).Labels.alert_type "podRestarts"}}
The Pod {{ (index .Alerts 0).Labels.pod_name}} restarts {{ (index .Alerts 0).Labels.restart_times}} times in {{ (index .Alerts 0).Labels.restart_interval}} sec
{{ else if eq (index .Alerts 0).Labels.alert_type "systemService"}}
The system component {{ (index .Alerts 0).Labels.component_name}} is not running
{{ else if eq (index .Alerts 0).Labels.alert_type "workload"}}
The workload {{ (index .Alerts 0).Labels.workload_name}} has available replicas less than {{ (index .Alerts 0).Labels.available_percentage}}%
{{ end}}
{{ end}}
{{ define "slack.text" }}
{{ if eq (index .Alerts 0).Labels.alert_type "event"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Target: {{ (index .Alerts 0).Labels.target_name}}
Count: {{ (index .Alerts 0).Labels.event_count}}
Event Message: {{ (index .Alerts 0).Labels.event_message}}
First Seen: {{ (index .Alerts 0).Labels.event_firstseen}}
Last Seen: {{ (index .Alerts 0).Labels.event_lastseen}}
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeHealthy"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeCPU"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Used CPU: {{ (index .Alerts 0).Labels.used_cpu}} m
Total CPU: {{ (index .Alerts 0).Labels.total_cpu}} m
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeMemory"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Used Memory: {{ (index .Alerts 0).Labels.used_mem}}
Total Memory: {{ (index .Alerts 0).Labels.total_mem}}
{{ else if eq (index .Alerts 0).Labels.alert_type "podRestarts"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Namespace: {{ (index .Alerts 0).Labels.namespace}}
Container Name: {{(index .Alerts 0).Labels.container_name}}
{{ else if eq (index .Alerts 0).Labels.alert_type "podNotRunning"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Namespace: {{ (index .Alerts 0).Labels.namespace}}
Container Name: {{ (index .Alerts 0).Labels.container_name}}
{{ else if eq (index .Alerts 0).Labels.alert_type "podNotScheduled"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Namespace: {{ (index .Alerts 0).Labels.namespace}}
Pod Name: {{ (index .Alerts 0).Labels.pod_name}}
{{ else if eq (index .Alerts 0).Labels.alert_type "systemService"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
{{ else if eq (index .Alerts 0).Labels.alert_type "workload"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}
Severity: {{ (index .Alerts 0).Labels.severity}}
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}
Available Replicas: {{ (index .Alerts 0).Labels.available_replicas}}
Desired Replicas: {{ (index .Alerts 0).Labels.desired_replicas}}
{{ end}}
{{ if (index .Alerts 0).Labels.logs}}
Logs: {{ (index .Alerts 0).Labels.logs}}
{{ end}}
{{ end}}
{{ define "email.text" }}
{{ if eq (index .Alerts 0).Labels.alert_type "event"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Target: {{ (index .Alerts 0).Labels.target_name}}<br>
Count: {{ (index .Alerts 0).Labels.event_count}}<br>
Event Message: {{ (index .Alerts 0).Labels.event_message}}<br>
First Seen: {{ (index .Alerts 0).Labels.event_firstseen}}<br>
Last Seen: {{ (index .Alerts 0).Labels.event_lastseen}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeHealthy"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeCPU"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Used CPU: {{ (index .Alerts 0).Labels.used_cpu}} m<br>
Total CPU: {{ (index .Alerts 0).Labels.total_cpu}} m<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "nodeMemory"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Used Memory: {{ (index .Alerts 0).Labels.used_mem}}<br>
Total Memory: {{ (index .Alerts 0).Labels.total_mem}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "podRestarts"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Namespace: {{ (index .Alerts 0).Labels.namespace}}<br>
Container Name: {{(index .Alerts 0).Labels.container_name}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "podNotRunning"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Namespace: {{ (index .Alerts 0).Labels.namespace}}<br>
Container Name: {{ (index .Alerts 0).Labels.container_name}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "podNotScheduled"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Namespace: {{ (index .Alerts 0).Labels.namespace}}<br>
Pod Name: {{ (index .Alerts 0).Labels.pod_name}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "systemService"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
{{ else if eq (index .Alerts 0).Labels.alert_type "workload"}}
Alert Name: {{ (index .Alerts 0).Labels.alert_name}}<br>
Severity: {{ (index .Alerts 0).Labels.severity}}<br>
Cluster Name: {{(index .Alerts 0).Labels.cluster_name}}<br>
Available Replicas: {{ (index .Alerts 0).Labels.available_replicas}}<br>
Desired Replicas: {{ (index .Alerts 0).Labels.desired_replicas}}<br>
{{ end}}
{{ if (index .Alerts 0).Labels.logs}}
Logs: {{ (index .Alerts 0).Labels.logs}}
{{ end}}
{{ end}}
`
)