Skip to content

Commit 7106f07

Browse files
committed
fix(kubevirt-operator): move PrometheusRule to Helm-rendered template
Move alerts/PrometheusRule.yaml from raw-file loading (via Files.Glob) to templates/prometheusrule.yaml as a proper Helm template. Escape Prometheus template variables with {{ "{{" }} to prevent Helm from evaluating them during chart rendering. Remove templates/alerts.yaml which is now dead code since the alerts/ directory is empty. Signed-off-by: IvanHunters <[email protected]>
1 parent f45facc commit 7106f07

3 files changed

Lines changed: 38 additions & 49 deletions

File tree

‎packages/system/kubevirt-operator/alerts/PrometheusRule.yaml‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

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

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: PrometheusRule
3+
metadata:
4+
name: vm-not-running-alert
5+
spec:
6+
groups:
7+
- name: kubevirt-alerts
8+
rules:
9+
- alert: VMNotRunningFor10Minutes
10+
expr: |
11+
max_over_time(
12+
kubevirt_vm_info{
13+
status!="running",
14+
exported_namespace=~".+",
15+
name=~".+"
16+
}[10m]
17+
) == 1
18+
labels:
19+
severity: critical
20+
namespace: '{{ "{{" }} $labels.exported_namespace {{ "}}" }}'
21+
annotations:
22+
summary: 'VM {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} is not Running for more than 10 minutes'
23+
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.'
24+
- alert: VMINotRunningFor10Minutes
25+
expr: |
26+
max_over_time(
27+
kubevirt_vmi_info{
28+
phase!="running",
29+
exported_namespace=~".+",
30+
name=~".+"
31+
}[10m]
32+
) == 1
33+
labels:
34+
severity: critical
35+
namespace: '{{ "{{" }} $labels.exported_namespace {{ "}}" }}'
36+
annotations:
37+
summary: 'VMI {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} is not Running for more than 10 minutes'
38+
description: 'The VMI {{ "{{" }} $labels.name {{ "}}" }} in namespace {{ "{{" }} $labels.exported_namespace {{ "}}" }} has been in a non-Running state for more than 10 minutes. Please investigate the issue.'

0 commit comments

Comments
 (0)