-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcapacity.yaml
360 lines (350 loc) · 15.3 KB
/
capacity.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: capacity
spec:
groups:
- name: capacity.rules
rules:
- expr: |
sum(sum(kube_pod_container_resource_requests{resource="cpu", unit="core"}) by(pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)
record: capacity:node:cpu:requests
- expr: |
sum(sum(kube_pod_container_resource_limits{resource="cpu", unit="core"}) by(pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)
record: capacity:node:cpu:limits
- expr: |
kube_node_status_allocatable{resource="cpu", unit="core"} * on(node) group_left(role) kube_node_role
record: capacity:node:cpu:available
- expr: |
label_replace(instance:node_cpu:rate:sum, "node", "$1", "instance", "(.+)")
record: capacity:node:cpu:usage
- expr: |
sum(sum(kube_pod_container_resource_requests{resource="memory", unit="bytes"}) by(pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)
record: capacity:node:memory:requests
- expr: |
sum(sum(kube_pod_container_resource_limits{resource="memory", unit="bytes"}) by(pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)
record: capacity:node:memory:limits
- expr: |
kube_node_status_allocatable{resource="memory", unit="byte"} * on(node) group_left(role) kube_node_role
record: capacity:node:memory:available
- expr: |
sum(sum(container_memory_working_set_bytes) by (pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)
record: capacity:node:memory:usage
- expr: |
sum(sum(kube_pod_container_resource_requests{resource="cpu", unit="core"}) by(pod, namespace) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (namespace)
record: capacity:namespace:cpu:requests
- expr: |
sum(sum(kube_pod_container_resource_limits{resource="cpu", unit="core"}) by(pod, namespace) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (namespace)
record: capacity:namespace:cpu:limits
- expr: |
sum(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (pod, namespace) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (namespace)
record: capacity:namespace:cpu:usage
- expr: |
sum(sum(kube_pod_container_resource_requests{resource="memory", unit="bytes"}) by (pod, namespace) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (namespace)
record: capacity:namespace:memory:requests
- expr: |
sum(sum(kube_pod_container_resource_limits{resource="memory", unit="bytes"}) by(pod, namespace) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (namespace)
record: capacity:namespace:memory:limits
- expr: |
sum(sum(container_memory_working_set_bytes) by (pod, namespace) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (namespace)
record: capacity:namespace:memory:usage
- expr: |
sum(sum(sum(container_memory_working_set_bytes) by (pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node) * on(node) group_left(role) kube_node_role) by (role)
record: capacity:role:memory:usage
- expr: |
sum(sum(sum(kube_pod_container_resource_requests{resource="memory", unit="bytes"}) by(pod, node) * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node) * on(node) group_left(role) kube_node_role) by (role)
record: capacity:role:memory:requests
- name: capacity-pods.alerts
rules:
- alert: NodePodsCapacityHigh
annotations:
message: >-
Number of pods on node {{ $labels.node }} is high
expr: |
(kube_node_status_allocatable{resource="pods"} - on(node) sum(kube_pod_info * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)) < 30
for: 8h
labels:
type: capacity
source: user
severity: high
- alert: NodePodsCapacityCritical
annotations:
message: >-
Number of pods on node {{ $labels.node }} is critical
expr: |
(kube_node_status_allocatable{resource="pods"} - on(node) sum(kube_pod_info * on(pod) group_left max(kube_pod_status_phase{phase="Running"}) by (pod)) by (node)) < 10
for: 2h
labels:
type: capacity
source: user
severity: critical
- name: capacity-cpu.alerts
rules:
- alert: NodeCpuRequestsWarning
annotations:
message: >-
CPU requests on node {{ $labels.node }} are increasing
expr: |
(capacity:node:cpu:requests / on(node) capacity:node:cpu:available) > 0.8
for: 8h
labels:
type: capacity
source: user
severity: warning
- alert: NodeCpuRequestsHigh
annotations:
message: >-
CPU requests on node {{ $labels.node }} are high
expr: |
(capacity:node:cpu:requests / on(node) capacity:node:cpu:available) > 0.9
for: 2h
labels:
type: capacity
source: user
severity: high
- alert: NodeCpuRequestsCritical
annotations:
message: >-
CPU requests on node {{ $labels.node }} are critical
expr: |
(capacity:node:cpu:requests / on(node) capacity:node:cpu:available) > 0.95
for: 1h
labels:
type: capacity
source: user
severity: critical
- alert: NodeCpuUsageWarning
annotations:
message: >-
CPU usage on node {{ $labels.node }} is increasing
expr: |
(capacity:node:cpu:usage / on(node) capacity:node:cpu:available) > 0.7
for: 8h
labels:
type: capacity
source: user
severity: warning
- alert: NodeCpuUsageHigh
annotations:
message: >-
CPU usage on node {{ $labels.node }} is high
expr: |
(capacity:node:cpu:usage / on(node) capacity:node:cpu:available) > 0.8
for: 4h
labels:
type: capacity
source: user
severity: high
- alert: NodeCpuUsageCritical
annotations:
message: >-
CPU usage on node {{ $labels.node }} is critical
expr: |
(capacity:node:cpu:usage / on(node) capacity:node:cpu:available) > 0.9
for: 2h
labels:
type: capacity
source: user
severity: critical
- name: capacity-memory.alerts
rules:
- alert: NodeMemoryRequestsWarning
annotations:
message: >-
Memory requests on node {{ $labels.node }} are increasing
expr: |
(capacity:node:memory:requests / on(node) capacity:node:memory:available) > 0.85
for: 8h
labels:
type: capacity
source: user
severity: warning
- alert: NodeMemoryRequestsHigh
annotations:
message: >-
Memory requests on node {{ $labels.node }} are high
expr: |
(capacity:node:memory:requests / on(node) capacity:node:memory:available) > 0.9
for: 2h
labels:
type: capacity
source: user
severity: high
- alert: NodeMemoryRequestsCritical
annotations:
message: >-
Memory requests on node {{ $labels.node }} are critical
expr: |
(capacity:node:memory:requests / on(node) capacity:node:memory:available) > 0.95
for: 1h
labels:
type: capacity
source: user
severity: critical
- alert: NodeMemoryUsageWarning
annotations:
message: >-
Memory usage on node {{ $labels.node }} is increasing
expr: |
(capacity:node:memory:usage / on(node) capacity:node:memory:available) > 0.75
for: 8h
labels:
type: capacity
source: user
severity: warning
- alert: NodeMemoryUsageHigh
annotations:
message: >-
Memory usage on node {{ $labels.node }} is high
expr: |
(capacity:node:memory:usage / on(node) capacity:node:memory:available) > 0.85
for: 4h
labels:
type: capacity
source: user
severity: high
- alert: NodeMemoryUsageCritical
annotations:
message: >-
Memory usage on node {{ $labels.node }} is critical
expr: |
(capacity:node:memory:usage / on(node) capacity:node:memory:available) > 0.9
for: 2h
labels:
type: capacity
source: user
severity: critical
- alert: ClusterAvailabilityNotice
expr: |
(capacity:role:memory:requests{role="worker"} / sum(capacity:node:memory:available{role="worker"}) by (role)) >= 0.7
for: 12h
annotations:
message: >-
The cluster memory requests are increasing. This will impact cluster availability.
labels:
type: capacity
source: user
severity: info
- alert: ClusterAvailabilityNotice2
expr: |
(capacity:role:memory:requests{role="worker"} / sum(capacity:node:memory:available{role="worker"}) by (role)) >= 0.8
for: 8h
annotations:
message: >-
The cluster memory requests are too high. Cluster availability can be impacted.
labels:
type: capacity
source: user
severity: warning
- alert: ClusterAvailabilityWarning
expr: |
(capacity:role:memory:usage{role="worker"} / sum(capacity:node:memory:available{role="worker"}) by (role)) > 0.6
for: 8h
annotations:
message: >-
The cluster memory usage is increasing. Soon there will be not enough resources to meet the availability requirements.
labels:
type: capacity
source: user
severity: warning
- alert: ClusterAvailabilityDegraded
expr: |
(capacity:role:memory:usage{role="worker"} / sum(capacity:node:memory:available{role="worker"}) by (role)) > 0.66
for: 12h
annotations:
message: >-
The cluster availability is degraded. There is not enough memory to meet the availability requirements.
labels:
type: capacity
source: user
severity: high
- alert: ClusterAvailabilityCritical
expr: |
(capacity:role:memory:usage{role="worker"} / sum(capacity:node:memory:available{role="worker"}) by (role)) >= 0.85
for: 4h
annotations:
message: >-
The cluster availability is critical. Reduce memory usage or add additional resources.
labels:
type: capacity
source: user
severity: critical
- name: capacity-storage.alerts
rules:
- alert: PvcStorageHigh
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} is above 90%
expr: |
(1 - (kubelet_volume_stats_available_bytes / on(persistentvolumeclaim, namespace) kubelet_volume_stats_capacity_bytes)) > 0.90
for: 30m
labels:
type: capacity
source: user
severity: high
- alert: PvcStorageCritical
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} is critical (> 95%)
expr: |
(1 - (kubelet_volume_stats_available_bytes / on(persistentvolumeclaim, namespace) kubelet_volume_stats_capacity_bytes)) > 0.95
for: 10m
labels:
type: capacity
source: user
severity: critical
- alert: PvcPredictionWarning
for: 2h
labels:
type: capacity
source: user
severity: warning
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} will be full in 24 hours
expr: |
(1 - (predict_linear(kubelet_volume_stats_available_bytes[5h], 3600 * 24) / on(persistentvolumeclaim, namespace, node) max_over_time(kubelet_volume_stats_capacity_bytes[5h]))) >= 1
- alert: PvcPredictionWarning2
for: 1h
labels:
type: capacity
source: user
severity: warning
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} will be full in 12 hours
expr: |
(1 - (predict_linear(kubelet_volume_stats_available_bytes[3h], 3600 * 12) / on(persistentvolumeclaim, namespace, node) max_over_time(kubelet_volume_stats_capacity_bytes[3h]))) >= 1
- alert: PvcPredictionWarning3
for: 1h
labels:
type: capacity
source: user
severity: warning
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} will be full in 6 hours
expr: |
(1 - (predict_linear(kubelet_volume_stats_available_bytes[2h], 3600 * 6) / on(persistentvolumeclaim, namespace, node) max_over_time(kubelet_volume_stats_capacity_bytes[2h]))) >= 1
- alert: PvcPredictionHigh
for: 30m
labels:
type: capacity
source: user
severity: high
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} will be full in 3 hours
expr: |
(1 - (predict_linear(kubelet_volume_stats_available_bytes[1h], 3600 * 3) / on(persistentvolumeclaim, namespace, node) max_over_time(kubelet_volume_stats_capacity_bytes[1h]))) >= 1
- alert: PvcPredictionCritical
for: 15m
labels:
type: capacity
source: user
severity: critical
annotations:
message: >-
Storage on PVC {{ $labels.persistentvolumeclaim }} in namespace {{ $labels.namespace }} will be full in 1 hour
expr: |
(1 - (predict_linear(kubelet_volume_stats_available_bytes[15m], 3600 * 1) / on(persistentvolumeclaim, namespace, node) max_over_time(kubelet_volume_stats_capacity_bytes[15m]))) >= 1