forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprom-rules-tests.yaml
735 lines (687 loc) · 34.1 KB
/
prom-rules-tests.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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
---
rule_files:
- /tmp/rules.verify
group_eval_order:
- kubevirt.rules
#information about this format can be found in: https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/
tests:
# Pod is using more CPU than expected
- interval: 1m
input_series:
- series: 'node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate{namespace="ci",pod="virt-controller-8546c99968-x9jgg",node="node1"}'
values: '2+0x10'
- series: 'kube_pod_container_resource_requests{namespace="ci",container="virt-controller",resource="cpu",pod="virt-controller-8546c99968-x9jgg",node="node1"}'
values: '0+0x6'
alert_rule_test:
- eval_time: 5m
alertname: KubeVirtComponentExceedsRequestedCPU
exp_alerts:
- exp_annotations:
description: "Container virt-controller in pod virt-controller-8546c99968-x9jgg cpu usage exceeds the CPU requested"
summary: "The container is using more CPU than what is defined in the containers resource requests"
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubeVirtComponentExceedsRequestedCPU"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
pod: "virt-controller-8546c99968-x9jgg"
container: "virt-controller"
namespace: ci
node: node1
resource: cpu
# Pod is using more memory than expected
- interval: 1m
input_series:
- series: 'container_memory_working_set_bytes{namespace="ci",container="",pod="virt-controller-8546c99968-x9jgg",node="node1"}'
values: "157286400 157286400 157286400 157286400 157286400 157286400 157286400 157286400"
- series: 'kube_pod_container_resource_requests{namespace="ci",container="virt-controller",resource="memory",pod="virt-controller-8546c99968-x9jgg",node="node1"}'
values: "118325248 118325248 118325248 118325248 118325248 118325248 118325248 118325248"
alert_rule_test:
- eval_time: 5m
alertname: KubeVirtComponentExceedsRequestedMemory
exp_alerts:
- exp_annotations:
description: "Container virt-controller in pod virt-controller-8546c99968-x9jgg memory usage exceeds the memory requested"
summary: "The container is using more memory than what is defined in the containers resource requests"
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubeVirtComponentExceedsRequestedMemory"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
namespace: ci
node: "node1"
pod: "virt-controller-8546c99968-x9jgg"
resource: "memory"
container: virt-controller
# Alerts to test whether our operators are up or not
- interval: 1m
input_series:
- series: 'up{namespace="ci", pod="virt-api-1"}'
values: "_ _ _ _ _ _ _ _ _ _ _ 0 0 0 0 0 0 1"
- series: 'up{namespace="ci", pod="virt-controller-1"}'
values: "_ _ _ _ _ _ _ _ _ _ _ 0 0 0 0 0 0 1"
- series: 'up{namespace="ci", pod="virt-operator-1"}'
values: "_ _ _ _ _ _ _ _ _ _ _ 0 0 0 0 0 0 1"
alert_rule_test:
# it must not trigger before 10m
- eval_time: 8m
alertname: VirtAPIDown
exp_alerts: []
- eval_time: 8m
alertname: VirtControllerDown
exp_alerts: [ ]
- eval_time: 8m
alertname: VirtOperatorDown
exp_alerts: [ ]
# it must trigger when there is no data
- eval_time: 10m
alertname: VirtAPIDown
exp_alerts:
- exp_annotations:
summary: "All virt-api servers are down."
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtAPIDown"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 10m
alertname: VirtControllerDown
exp_alerts:
- exp_annotations:
summary: "No running virt-controller was detected for the last 10 min."
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtControllerDown"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 10m
alertname: VirtOperatorDown
exp_alerts:
- exp_annotations:
summary: "All virt-operator servers are down."
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtOperatorDown"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# it must trigger when operators are not healthy
- eval_time: 16m
alertname: VirtAPIDown
exp_alerts:
- exp_annotations:
summary: "All virt-api servers are down."
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtAPIDown"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 16m
alertname: VirtControllerDown
exp_alerts:
- exp_annotations:
summary: "No running virt-controller was detected for the last 10 min."
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtControllerDown"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 16m
alertname: VirtOperatorDown
exp_alerts:
- exp_annotations:
summary: "All virt-operator servers are down."
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtOperatorDown"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# it must not trigger when operators are healthy
- eval_time: 17m
alertname: VirtAPIDown
exp_alerts: []
- eval_time: 17m
alertname: VirtControllerDown
exp_alerts: [ ]
- eval_time: 17m
alertname: VirtOperatorDown
exp_alerts: [ ]
# vmi running on a node with an unready virt-handler pod
- interval: 1m
input_series:
- series: 'kube_pod_info{pod="virt-launcher-testvm-123", node="node01"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_status_ready{pod="virt-handler-asdf", condition="true"}'
values: '_ _ _ _ _ _ _ _ _ _ _'
- series: 'kube_pod_status_ready{pod="virt-handler-asdf", condition="false"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_info{pod="virt-handler-asdf", node="node01"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_info{pod="virt-launcher-vmi", node="node02"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_status_ready{pod="virt-handler-asdfg", condition="true"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_info{pod="virt-handler-asdfg", node="node02"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
alert_rule_test:
# no alert before 10 minutes
- eval_time: 9m
alertname: OrphanedVirtualMachineInstances
exp_alerts: [ ]
- eval_time: 10m
alertname: OrphanedVirtualMachineInstances
exp_alerts:
- exp_annotations:
summary: "No ready virt-handler pod detected on node node01 with running vmis for more than 10 minutes"
runbook_url: "https://kubevirt.io/monitoring/runbooks/OrphanedVirtualMachineInstances"
exp_labels:
node: "node01"
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# vmi running on a node without a virt-handler pod
- interval: 1m
input_series:
- series: 'kube_pod_info{pod="virt-launcher-testvm-123", node="node01"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_status_ready{pod="virt-handler-asdf", condition="true"}'
values: '_ _ _ _ _ _ _ _ _ _ _'
- series: 'kube_pod_info{pod="virt-handler-asdf", node="node01"}'
values: '_ _ _ _ _ _ _ _ _ _ _'
- series: 'kube_pod_info{pod="virt-launcher-vmi", node="node02"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_status_ready{pod="virt-handler-asdfg", condition="true"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
- series: 'kube_pod_info{pod="virt-handler-asdfg", node="node02"}'
values: '1 1 1 1 1 1 1 1 1 1 1'
alert_rule_test:
# no alert before 10 minutes
- eval_time: 9m
alertname: OrphanedVirtualMachineInstances
exp_alerts: [ ]
- eval_time: 10m
alertname: OrphanedVirtualMachineInstances
exp_alerts:
- exp_annotations:
summary: "No ready virt-handler pod detected on node node01 with running vmis for more than 10 minutes"
runbook_url: "https://kubevirt.io/monitoring/runbooks/OrphanedVirtualMachineInstances"
exp_labels:
node: "node01"
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# Some virt controllers are not ready
- interval: 1m
input_series:
- series: 'kubevirt_virt_controller_ready{namespace="ci", pod="virt-controller-1"}'
values: '1+0x11'
- series: 'kubevirt_virt_controller_ready{namespace="ci", pod="virt-controller-2"}'
values: '0+0x11'
- series: 'up{namespace="ci", pod="virt-controller-1"}'
values: '1+0x11'
- series: 'up{namespace="ci", pod="virt-controller-2"}'
values: '1+0x11'
alert_rule_test:
- eval_time: 10m
alertname: LowReadyVirtControllersCount
exp_alerts:
- exp_annotations:
summary: "Some virt controllers are running but not ready."
runbook_url: "https://kubevirt.io/monitoring/runbooks/LowReadyVirtControllersCount"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# All virt controllers are not ready
- interval: 1m
input_series:
- series: 'kubevirt_virt_controller_ready{namespace="ci", pod="virt-controller-1"}'
values: "0 0 0 0 0 0 0 0 0 0 0"
alert_rule_test:
# no alert before 10 minutes
- eval_time: 9m
alertname: NoReadyVirtController
exp_alerts: [ ]
- eval_time: 10m
alertname: NoReadyVirtController
exp_alerts:
- exp_annotations:
summary: "No ready virt-controller was detected for the last 10 min."
runbook_url: "https://kubevirt.io/monitoring/runbooks/NoReadyVirtController"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# All virt controllers are not ready (ImagePullBackOff)
- interval: 1m
input_series:
- series: 'kubevirt_virt_controller_ready{namespace="ci", pod="virt-controller-1"}'
values: "stale stale stale stale stale stale stale stale stale stale"
alert_rule_test:
# no alert before 10 minutes
- eval_time: 9m
alertname: NoReadyVirtController
exp_alerts: [ ]
- eval_time: 10m
alertname: NoReadyVirtController
exp_alerts:
- exp_annotations:
summary: "No ready virt-controller was detected for the last 10 min."
runbook_url: "https://kubevirt.io/monitoring/runbooks/NoReadyVirtController"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# All virt operators are not ready (ImagePullBackOff)
- interval: 1m
input_series:
- series: 'kubevirt_virt_operator_ready{namespace="ci", pod="virt-operator-1"}'
values: "stale stale stale stale stale stale stale stale stale stale"
alert_rule_test:
# no alert before 10 minutes
- eval_time: 9m
alertname: NoReadyVirtOperator
exp_alerts: [ ]
- eval_time: 10m
alertname: NoReadyVirtOperator
exp_alerts:
- exp_annotations:
summary: "No ready virt-operator was detected for the last 10 min."
runbook_url: "https://kubevirt.io/monitoring/runbooks/NoReadyVirtOperator"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# All virt operators are not ready
- interval: 1m
input_series:
- series: 'kubevirt_virt_operator_ready{namespace="ci", pod="virt-operator-1"}'
values: "0 0 0 0 0 0 0 0 0 0 0"
alert_rule_test:
# no alert before 10 minutes
- eval_time: 9m
alertname: NoReadyVirtOperator
exp_alerts: [ ]
- eval_time: 10m
alertname: NoReadyVirtOperator
exp_alerts:
- exp_annotations:
summary: "No ready virt-operator was detected for the last 10 min."
runbook_url: "https://kubevirt.io/monitoring/runbooks/NoReadyVirtOperator"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# Burst REST errors
# values: '0+10x20' == values: "0 10 20 30 40 ... 190"
# values: '0+100x20' == values :"0 100 200 .... 1900"
# so now for EACH POD the total requests should be 10+20+30+..+190+100+200+300+...+1900
# and the number of requests with error code should be 190+100+200+300+...+1900 which is more than 80% of the total requests
# in each 5 minutes interval of the test and the error condition(more than 80% of the requests has error code) is true for
# more than 5 minutes(because each test run for 20 minutes) which should fire an alert for EACH POD
# values : 0+100x15 0+100x5 == :"0 100 200 .... 1400 0 100 200 300 400" we should treat values : `0+100x20` and
# values : `0+100x15 0+100x5` the same way because prometheus counters might reset
- interval: 1m
input_series:
- series: 'rest_client_requests_total{namespace="ci", pod="virt-controller-1", code="200"}'
values: '0+10x20'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-controller-1", code="400"}'
values: '0+100x15 0+100x5'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-operator-1", code="200"}'
values: '0+10x20'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-operator-1", code="400"}'
values: '0+100x15 0+100x5'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-handler-1", code="200"}'
values: '0+10x20'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-handler-1", code="500"}'
values: '0+100x15 0+100x5'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-api-1", code="200"}'
values: '0+10x20'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-api-1", code="500"}'
values: '0+100x15 0+100x5'
alert_rule_test:
- eval_time: 20m
alertname: VirtControllerRESTErrorsBurst
exp_alerts:
- exp_annotations:
summary: "More than 80% of the rest calls failed in virt-controller for the last 5 minutes"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtControllerRESTErrorsBurst"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 20m
alertname: VirtOperatorRESTErrorsBurst
exp_alerts:
- exp_annotations:
summary: "More than 80% of the rest calls failed in virt-operator for the last 5 minutes"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtOperatorRESTErrorsBurst"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 20m
alertname: VirtHandlerRESTErrorsBurst
exp_alerts:
- exp_annotations:
summary: "More than 80% of the rest calls failed in virt-handler for the last 5 minutes"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtHandlerRESTErrorsBurst"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 20m
alertname: VirtApiRESTErrorsBurst
exp_alerts:
- exp_annotations:
summary: "More than 80% of the rest calls failed in virt-api for the last 5 minutes"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtApiRESTErrorsBurst"
exp_labels:
severity: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# values: '0+10x100' == values: "0 10 20 30 40 ... 990"
# values: '0+5x100' == values :"0 5 10 .... 495"
# so now for EACH POD the total requests should be 10+20+30+..+990+5+10+15+...+495
# and the number of requests with error code should be 5+10+15+...+495 which is more than 5% of the total requests
# the error condition(more than 5% of the requests has error code) is true which should fire an alert for EACH POD
# High REST errors
# values : '0+5x90 0+5x10' == :"0 5 10 .... 445 0 5 10 ... 45" we should treat values : '0+5x100' and
# values : '0+5x90 0+5x10' the same way because prometheus counters might reset
- interval: 1m
input_series:
- series: 'rest_client_requests_total{namespace="ci", pod="virt-controller-1", code="200"}'
values: '0+10x100'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-controller-1", code="400"}'
values: '0+5x90 0+5x10'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-operator-1", code="200"}'
values: '0+10x100'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-operator-1", code="400"}'
values: '0+5x90 0+5x10'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-handler-1", code="200"}'
values: '0+10x100'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-handler-1", code="500"}'
values: '0+5x90 0+5x10'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-api-1", code="200"}'
values: '0+10x100'
- series: 'rest_client_requests_total{namespace="ci", pod="virt-api-1", code="500"}'
values: '0+5x90 0+5x10'
alert_rule_test:
- eval_time: 100m
alertname: VirtControllerRESTErrorsHigh
exp_alerts:
- exp_annotations:
summary: "More than 5% of the rest calls failed in virt-controller for the last hour"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtControllerRESTErrorsHigh"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 100m
alertname: VirtOperatorRESTErrorsHigh
exp_alerts:
- exp_annotations:
summary: "More than 5% of the rest calls failed in virt-operator for the last hour"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtOperatorRESTErrorsHigh"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 100m
alertname: VirtHandlerRESTErrorsHigh
exp_alerts:
- exp_annotations:
summary: "More than 5% of the rest calls failed in virt-handler for the last hour"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtHandlerRESTErrorsHigh"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
- eval_time: 100m
alertname: VirtApiRESTErrorsHigh
exp_alerts:
- exp_annotations:
summary: "More than 5% of the rest calls failed in virt-api for the last hour"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VirtApiRESTErrorsHigh"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# Some nodes without KVM resources
- interval: 1m
input_series:
- series: 'kube_node_status_allocatable{resource="devices_kubevirt_io_kvm", node ="node1"}'
values: "110 110 110 110 110 110"
- series: 'kube_node_status_allocatable{resource="devices_kubevirt_io_kvm", node ="node2 "}'
values: "0 0 0 0 0 0"
alert_rule_test:
- eval_time: 5m
alertname: LowKVMNodesCount
exp_alerts:
- exp_annotations:
description: "Low number of nodes with KVM resource available."
summary: "At least two nodes with kvm resource required for VM live migration."
runbook_url: "https://kubevirt.io/monitoring/runbooks/LowKVMNodesCount"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# All nodes without KVM resources
- interval: 1m
input_series:
- series: 'kube_node_status_allocatable{resource="devices_kubevirt_io_kvm", node ="node1"}'
values: "0 0 0 0 0 0"
- series: 'kube_node_status_allocatable{resource="devices_kubevirt_io_kvm", node ="node2 "}'
values: "0 0 0 0 0 0"
alert_rule_test:
- eval_time: 5m
alertname: LowKVMNodesCount
exp_alerts:
- exp_annotations:
description: "Low number of nodes with KVM resource available."
summary: "At least two nodes with kvm resource required for VM live migration."
runbook_url: "https://kubevirt.io/monitoring/runbooks/LowKVMNodesCount"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
# Two nodes with KVM resources
- interval: 1m
input_series:
- series: 'kube_node_status_allocatable{resource="devices_kubevirt_io_kvm", node ="node1"}'
values: "110 110 110 110 110 110"
- series: 'kube_node_status_allocatable{resource="devices_kubevirt_io_kvm", node ="node2 "}'
values: "110 110 110 110 110 110"
alert_rule_test:
- eval_time: 5m
alertname: LowKVMNodesCount
exp_alerts: []
# Memory utilization less than 20MB close to requested memory - based on memory working set
- interval: 1m
input_series:
- series: 'kube_pod_container_resource_requests{pod="virt-launcher-testvm-123", container="compute", resource="memory", namespace="ns-test"}'
values: "67108864 67108864 67108864 67108864"
- series: 'container_memory_working_set_bytes{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "47185920 48234496 48234496 49283072"
- series: 'container_memory_rss{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "19922944 18874368 18874368 17825792"
alert_rule_test:
- eval_time: 1m
alertname: KubevirtVmHighMemoryUsage
exp_alerts:
- exp_annotations:
description: "Container compute in pod virt-launcher-testvm-123 in namespace ns-test free memory is less than 20 MB and it is close to requested memory"
summary: "VM is at risk of being evicted and in serious cases of memory exhaustion being terminated by the runtime."
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubevirtVmHighMemoryUsage"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
pod: "virt-launcher-testvm-123"
container: "compute"
namespace: "ns-test"
# Memory utilization less than 20MB close to requested memory - based on memory RSS
- interval: 1m
input_series:
- series: 'kube_pod_container_resource_requests{pod="virt-launcher-testvm-123", container="compute", resource="memory", namespace="ns-test"}'
values: "67108864 67108864 67108864 67108864"
- series: 'container_memory_working_set_bytes{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "19922944 18874368 18874368 17825792"
- series: 'container_memory_rss{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "47185920 48234496 48234496 49283072"
alert_rule_test:
- eval_time: 1m
alertname: KubevirtVmHighMemoryUsage
exp_alerts:
- exp_annotations:
description: "Container compute in pod virt-launcher-testvm-123 in namespace ns-test free memory is less than 20 MB and it is close to requested memory"
summary: "VM is at risk of being evicted and in serious cases of memory exhaustion being terminated by the runtime."
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubevirtVmHighMemoryUsage"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
pod: "virt-launcher-testvm-123"
container: "compute"
namespace: "ns-test"
# Memory utilization less than 20MB close to requested memory - based on memory RSS and memory working set
- interval: 1m
input_series:
- series: 'kube_pod_container_resource_requests{pod="virt-launcher-testvm-123", container="compute", resource="memory", namespace="ns-test"}'
values: "67108864 67108864 67108864 67108864"
- series: 'container_memory_working_set_bytes{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "47185920 48234496 48234496 49283072"
- series: 'container_memory_rss{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "47185920 48234496 48234496 49283072"
alert_rule_test:
- eval_time: 1m
alertname: KubevirtVmHighMemoryUsage
exp_alerts:
- exp_annotations:
description: "Container compute in pod virt-launcher-testvm-123 in namespace ns-test free memory is less than 20 MB and it is close to requested memory"
summary: "VM is at risk of being evicted and in serious cases of memory exhaustion being terminated by the runtime."
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubevirtVmHighMemoryUsage"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
pod: "virt-launcher-testvm-123"
container: "compute"
namespace: "ns-test"
# Memory utilization more than 20MB close to requested memory
- interval: 30s
input_series:
- series: 'kube_pod_container_resource_requests{pod="virt-launcher-testvm-123", container="compute", resource="memory", namespace="ns-test"}'
values: "67108864 67108864 67108864 67108864"
- series: 'container_memory_working_set_bytes{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "19922944 18874368 18874368 17825792"
- series: 'container_memory_rss{pod="virt-launcher-testvm-123", container="compute", namespace="ns-test"}'
values: "19922944 18874368 18874368 17825792"
alert_rule_test:
- eval_time: 1m
alertname: KubevirtVmHighMemoryUsage
exp_alerts: []
# VM eviction strategy is set but vm is not migratable
- interval: 1m
input_series:
- series: 'kubevirt_vmi_non_evictable{node="node1", namespace="ns-test", name="vm-evict-nonmigratable"}'
values: "1 1 1 1 1 1 1 1"
alert_rule_test:
- eval_time: 1m
alertname: VMCannotBeEvicted
exp_alerts:
- exp_annotations:
description: "Eviction policy for vm-evict-nonmigratable (on node node1) is set to Live Migration but the VM is not migratable"
summary: "The VM's eviction strategy is set to Live Migration but the VM is not migratable"
runbook_url: "https://kubevirt.io/monitoring/runbooks/VMCannotBeEvicted"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
name: "vm-evict-nonmigratable"
namespace: "ns-test"
node: "node1"
# VM eviction strategy is set and vm is migratable
- interval: 1m
input_series:
- series: 'kubevirt_vmi_non_evictable{node="node1", namespace="ns-test", name="vm-evict-migratable"}'
values: "0 0 0 0 0 0 0 0 "
alert_rule_test:
- eval_time: 1m
alertname: VMCannotBeEvicted
exp_alerts: []
# Test recording rule
- interval: 1m
input_series:
# In reality there are many labels on these metrics
# they are the same except the ones containing vm name like "name" in the example below
- series: 'kubevirt_vmi_memory_available_bytes{container="virt-handler", name="vm-example-1", namespace="default", node="node-1"}'
# time: 0 1 2 3
values: "1376882688 1376882688 1376882688 1376882688"
- series: 'kubevirt_vmi_memory_available_bytes{container="virt-handler", name="vm-example-2", namespace="default", node="node-1"}'
# time: 0 1 2 3
values: "2893266944 2893266944 2893266944 2893266944"
- series: 'kubevirt_vmi_memory_usable_bytes{container="virt-handler", name="vm-example-1", namespace="default", node="node-1"}'
# time: 0 1 2 3
values: "1073176576 1073176576 1073176576 1273176576"
- series: 'kubevirt_vmi_memory_usable_bytes{container="virt-handler", name="vm-example-2", namespace="default", node="node-1"}'
# time: 0 1 2 3
values: "2448936960 2448936960 2448936960 2658936964"
promql_expr_test:
- expr: 'kubevirt_vmi_memory_used_bytes'
eval_time: 1m
exp_samples:
- labels: 'kubevirt_vmi_memory_used_bytes{container="virt-handler", name="vm-example-1", namespace="default", node="node-1"}'
value: 303706112
- labels: 'kubevirt_vmi_memory_used_bytes{container="virt-handler", name="vm-example-2", namespace="default", node="node-1"}'
value: 444329984
- expr: 'kubevirt_vmi_memory_used_bytes'
eval_time: 3m
exp_samples:
- labels: 'kubevirt_vmi_memory_used_bytes{container="virt-handler", name="vm-example-1", namespace="default", node="node-1"}'
value: 103706112
- labels: 'kubevirt_vmi_memory_used_bytes{container="virt-handler", name="vm-example-2", namespace="default", node="node-1"}'
value: 234329980
# Excessive VMI Migrations in a period of time
# Simulating metric resets at time slots 5 and 9
- interval: 1h
input_series:
- series: 'kubevirt_migrate_vmi_succeeded_total{vmi="vmi-example-1", source="node-1", target="node-2"}'
# time: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
values: "_ 1 2 2 3 _ 1 2 2 _ _ 1 2 3+0x13" # 7 increases, in samples: 2,4,6,7,11,12,13
- series: 'kubevirt_migrate_vmi_succeeded_total{vmi="vmi-example-1", source="node-2", target="node-1"}'
# time: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
values: "_ _ 1 2 2 _ _ 1 2 _ 1 2 2 2+0x13" # 6 increases, in samples: 2,3,7,8,10,11
alert_rule_test:
# at 11h, there are total of 11 migrations made on a single VMI, so the alert should not be fired.
- eval_time: 11h
alertname: KubeVirtVMIExcessiveMigrations
exp_alerts: []
# at 16h, there are total of 13 migrations made on a single VMI, thus the alert is expected to be fired.
- eval_time: 16h
alertname: KubeVirtVMIExcessiveMigrations
exp_alerts:
- exp_annotations:
description: "VirtualMachineInstance vmi-example-1 has been migrated more than 12 times during the last 24 hours"
summary: "An excessive amount of migrations have been detected on a VirtualMachineInstance in the last 24 hours."
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubeVirtVMIExcessiveMigrations"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
vmi: vmi-example-1
- eval_time: 24h
alertname: KubeVirtVMIExcessiveMigrations
exp_alerts:
- exp_annotations:
description: "VirtualMachineInstance vmi-example-1 has been migrated more than 12 times during the last 24 hours"
summary: "An excessive amount of migrations have been detected on a VirtualMachineInstance in the last 24 hours."
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubeVirtVMIExcessiveMigrations"
exp_labels:
severity: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "kubevirt"
vmi: vmi-example-1
# since the first increase occurred in 2h, will need to evaluate at 26h to disregard the first increase and clear the alert.
- eval_time: 26h
alertname: KubeVirtVMIExcessiveMigrations
exp_alerts: []