Skip to content

Commit 000157f

Browse files
committed
fix(kubevirt-operator): use instant vector with for: 10m instead of max_over_time
Replace max_over_time([10m]) == 1 with an instant vector selector and a top-level for: 10m clause. The previous expression fired as long as the metric was non-running at any point in the last 10 minutes; the new expression fires only when the condition is sustained continuously for the full 10-minute window, matching the alert name semantics. Signed-off-by: IvanHunters <[email protected]>
1 parent 7106f07 commit 000157f

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

‎packages/system/kubevirt-operator/templates/prometheusrule.yaml‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ spec:
88
rules:
99
- alert: VMNotRunningFor10Minutes
1010
expr: |
11-
max_over_time(
12-
kubevirt_vm_info{
13-
status!="running",
14-
exported_namespace=~".+",
15-
name=~".+"
16-
}[10m]
17-
) == 1
11+
kubevirt_vm_info{
12+
status!="running",
13+
exported_namespace=~".+",
14+
name=~".+"
15+
} == 1
16+
for: 10m
1817
labels:
1918
severity: critical
2019
namespace: '{{ "{{" }} $labels.exported_namespace {{ "}}" }}'
@@ -23,13 +22,12 @@ spec:
2322
description: 'The VM {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} has been in a non-Running state for more than 10 minutes. Please investigate the issue.'
2423
- alert: VMINotRunningFor10Minutes
2524
expr: |
26-
max_over_time(
27-
kubevirt_vmi_info{
28-
phase!="running",
29-
exported_namespace=~".+",
30-
name=~".+"
31-
}[10m]
32-
) == 1
25+
kubevirt_vmi_info{
26+
phase!="running",
27+
exported_namespace=~".+",
28+
name=~".+"
29+
} == 1
30+
for: 10m
3331
labels:
3432
severity: critical
3533
namespace: '{{ "{{" }} $labels.exported_namespace {{ "}}" }}'

0 commit comments

Comments
 (0)