Skip to content

Commit

Permalink
Add operator_health_impact label to CNAO alerts (#1494)
Browse files Browse the repository at this point in the history
Signed-off-by: assafad <aadmi@redhat.com>

Signed-off-by: assafad <aadmi@redhat.com>
  • Loading branch information
assafad authored Jan 1, 2023
1 parent a1250e2 commit bb263a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions data/monitoring/prom-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
for: 5m
labels:
severity: warning
operator_health_impact: warning
kubernetes_operator_part_of: kubevirt
kubernetes_operator_component: cluster-network-addons-operator
- alert: NetworkAddonsConfigNotReady
Expand All @@ -30,6 +31,7 @@ spec:
for: 5m
labels:
severity: warning
operator_health_impact: warning
kubernetes_operator_part_of: kubevirt
kubernetes_operator_component: cluster-network-addons-operator
# +help:summary="Total count of duplicate KubeMacPool MAC addresses",type=Gauge
Expand All @@ -43,6 +45,7 @@ spec:
for: 5m
labels:
severity: warning
operator_health_impact: warning
kubernetes_operator_part_of: kubevirt
kubernetes_operator_component: cluster-network-addons-operator
# +help:summary="Total count of running KubeMacPool manager pods",type=Gauge
Expand All @@ -59,5 +62,6 @@ spec:
for: 5m
labels:
severity: critical
operator_health_impact: critical
kubernetes_operator_part_of: kubevirt
kubernetes_operator_component: cluster-network-addons-operator
4 changes: 4 additions & 0 deletions hack/prom-rule-ci/prom-rules-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tests:
runbook_url: "https://kubevirt.io/monitoring/runbooks/CnaoDown"
exp_labels:
severity: "warning"
operator_health_impact: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "cluster-network-addons-operator"
# CnaoDown negative tests
Expand Down Expand Up @@ -53,6 +54,7 @@ tests:
runbook_url: "https://kubevirt.io/monitoring/runbooks/NetworkAddonsConfigNotReady"
exp_labels:
severity: "warning"
operator_health_impact: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "cluster-network-addons-operator"

Expand Down Expand Up @@ -88,6 +90,7 @@ tests:
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubeMacPoolDuplicateMacsFound"
exp_labels:
severity: "warning"
operator_health_impact: "warning"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "cluster-network-addons-operator"

Expand Down Expand Up @@ -121,6 +124,7 @@ tests:
runbook_url: "https://kubevirt.io/monitoring/runbooks/KubeMacPoolDown"
exp_labels:
severity: "critical"
operator_health_impact: "critical"
kubernetes_operator_part_of: "kubevirt"
kubernetes_operator_component: "cluster-network-addons-operator"

Expand Down
7 changes: 7 additions & 0 deletions test/e2e/monitoring/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var _ = Context("Prometheus Rules", func() {
if len(rule.Alert) > 0 {
Expect(rule.Labels).ToNot(BeNil())
checkForSeverityLabel(rule)
checkForHealthImpactLabel(rule)
checkForPartOfLabel(rule)
checkForComponentLabel(rule)
}
Expand Down Expand Up @@ -97,6 +98,12 @@ func checkForSeverityLabel(rule monitoringv1.Rule) {
ExpectWithOffset(1, severity).To(BeElementOf("info", "warning", "critical"), fmt.Sprintf("%s severity label is not valid", rule.Alert))
}

func checkForHealthImpactLabel(rule monitoringv1.Rule) {
operatorHealthImpact, ok := rule.Labels["operator_health_impact"]
ExpectWithOffset(1, ok).To(BeTrue(), fmt.Sprintf("%s does not have operator_health_impact label", rule.Alert))
ExpectWithOffset(1, operatorHealthImpact).To(BeElementOf("none", "warning", "critical"), fmt.Sprintf("%s operator_health_impact label is not valid", rule.Alert))
}

func checkForPartOfLabel(rule monitoringv1.Rule) {
kubernetesOperatorPartOf, ok := rule.Labels["kubernetes_operator_part_of"]
ExpectWithOffset(1, ok).To(BeTrue(), fmt.Sprintf("%s does not have kubernetes_operator_part_of label", rule.Alert))
Expand Down

0 comments on commit bb263a3

Please sign in to comment.