-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigmap-prometheus-alerts.yaml
236 lines (222 loc) · 9.12 KB
/
configmap-prometheus-alerts.yaml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
apiVersion: v1
kind: ConfigMap
metadata:
name: metrics-alerts
namespace: {{ .Release.Namespace }}
data:
{{- $service := dict "service" "coderd" -}}
{{- with .Values.global.coder.alerts.coderd }} {{/* start-section */}}
coderd.yaml: |-
groups:
{{- with .groups.CPU }}
{{- $group := . }}
{{- if .enabled }}
- name: CPU Usage
rules:
{{ $alert := "CoderdCPUUsage" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: max by (pod) (rate(container_cpu_usage_seconds_total{ {{- include "coderd-selector" $ -}} }[{{- $group.period -}}])) / max by(pod) (kube_pod_container_resource_limits{ {{- include "coderd-selector" $ -}}, resource="cpu"}) > {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: The Coder instance {{ `{{ $labels.pod }}` }} is using high amounts of CPU, which may impact application performance.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- with .groups.Memory }}
{{- $group := . }}
{{- if .enabled }}
- name: Memory Usage
rules:
{{ $alert := "CoderdMemoryUsage" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: max by (pod) (container_memory_working_set_bytes{ {{- include "coderd-selector" $ -}} }) / max by (pod) (kube_pod_container_resource_limits{ {{- include "coderd-selector" $ -}}, resource="memory"}) > {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: The Coder instance {{ `{{ $labels.pod }}` }} is using high amounts of memory, which may lead to an Out-Of-Memory (OOM) error.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- with .groups.Restarts }}
{{- $group := . }}
{{- if .enabled }}
- name: Pod Restarts
rules:
{{ $alert := "CoderdRestarts" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: sum by(pod) (increase(kube_pod_container_status_restarts_total{ {{- include "coderd-selector" $ -}} }[{{- $group.period -}}])) > {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: The Coder instance {{ `{{ $labels.pod }}` }} has restarted multiple times in the last {{ $group.period -}}, which may indicate a CrashLoop.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- with .groups.Replicas }}
{{- $group := . }}
{{- if .enabled }}
- name: Coderd Replicas
rules:
{{ $alert := "CoderdReplicas" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: sum(up{ {{- include "coderd-selector" $ -}} }) < {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: Number of alive coderd replicas is below the threshold = {{ $threshold -}}.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- with .groups.WorkspaceBuildFailures }}
{{- $group := . }}
{{- if .enabled }}
- name: Coderd Workspace Build Failures
rules:
{{ $alert := "CoderdWorkspaceBuildFailures" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: sum(increase(coderd_workspace_builds_total{ {{- include "coderd-selector" $ -}} , status="failed" }[{{- $group.period -}}])) > {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: Workspace builds have failed multiple times in the last {{ $group.period -}}, which may indicate a broken Coder template.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- with .groups.IneligiblePrebuilds }}
{{- $group := . }}
{{- if .enabled }}
- name: Coderd Ineligible Prebuilds
rules:
{{ $alert := "CoderdIneligiblePrebuilds" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: max by (template_name, preset_name) (coderd_prebuilds_running - coderd_prebuilds_eligible) > 0
for: {{ $group.delay }}
annotations:
summary: >
{{ `{{ $value }}` }} prebuilt workspace(s) are currently ineligible for claiming for the "{{ `{{ $labels.template_name }}` }}" template and "{{ `{{ $labels.preset_name }}` }}" preset.
This usually indicates that the agent has not started correctly, or is still running its startup scripts after an extended period of time.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- end }} {{/* end-section */}}
{{- with .Values.global.coder.alerts.provisionerd }} {{/* start-section */}}
provisionerd.yaml: |-
groups:
{{- with .groups.Replicas }}
{{- $group := . }}
{{- if .enabled }}
- name: Provisionerd Replicas
rules:
{{ $alert := "ProvisionerdReplicas" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: sum(coderd_provisionerd_num_daemons{ {{- include "coderd-selector" $ -}} }) < {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: Number of alive provisionerd replicas is below the threshold = {{ $threshold -}}.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- end }} {{/* end-section */}}
{{- $service = dict "service" "enterprise" -}}
{{- with .Values.global.coder.alerts.enterprise }} {{/* start-section */}}
enterprise.yaml: |-
groups:
{{- with .groups.Licences }}
{{- $group := . }}
{{- if .enabled }}
- name: Licences
rules:
{{ $alert := "CoderLicenseSeats" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: 'max(coderd_license_active_users) / max(coderd_license_limit_users) >= {{- $threshold }}'
for: {{ $group.delay }}
annotations:
summary: Your Coder enterprise licence usage is now at {{ `{{ $value | humanizePercentage }}` }} capacity.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end }}
{{- end }}
{{- end }} {{/* end-section */}}
{{- $service = dict "service" "postgres" -}}
{{- with .Values.global.postgres }}
postgres.yaml: |-
groups:
{{- with .alerts.groups.Notifications }}
{{- $group := . -}}
{{- if .enabled }}
- name: Notifications
rules:
{{ $alert := "PostgresNotificationQueueFillingUp" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: {{ include "postgres-pubsub-queue-usage-metric-name" . }} > {{ $threshold }}
for: {{ $group.delay }}
annotations:
summary: The postgres instance {{ `{{ $labels.instance }}` }} has a notification that is filling up, which may impact application performance.
labels:
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end -}}
{{- end -}}
{{- with .alerts.groups.Basic }}
{{ $group := . -}}
{{- if .enabled }}
- name: Liveness
rules:
{{ $alert := "PostgresDown" }}
- alert: {{ $alert }}
expr: pg_up == 0
for: {{ $group.delay }}
annotations:
summary: The postgres instance {{ `{{ $labels.instance }}` }} is down!
labels:
severity: critical
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{ end }}
{{- with .alerts.groups.Connections }}
{{ $group := . -}}
{{- if .enabled }}
- name: Connections
rules:
{{ $alert := "PostgresConnectionsRunningLow" }}
{{- range $severity, $threshold := .thresholds }}
- alert: {{ $alert }}
expr: sum by (datname, instance) (pg_stat_activity_count) > on () group_left() (pg_settings_max_connections * {{ $threshold }})
for: {{ $group.delay }}
labels:
summary: The postgres instance {{ `{{ $labels.instance }}` }} is running low on connections which may impact application performance.
severity: {{ $severity }}
runbook_url: {{ template "runbook-url" (deepCopy $ | merge (dict "alert" $alert) $service) }}
{{- end }}
{{- end -}}
{{- end -}}
{{ end }}