Skip to content

Commit

Permalink
patch - adding severity option to prometheusrules alert (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrNovo committed May 12, 2024
1 parent 4b62434 commit d63821f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
for: 5m
annotations:
cxMinNonNullValuesPercentage: "20"
labels:
severity: critical
- name: example.rules2
interval: "70s"
rules:
Expand All @@ -33,4 +35,6 @@ spec:
expr: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) by (le, destination_workload)) > 0.2
for: 5m
annotations:
cxMinNonNullValuesPercentage: "20"
cxMinNonNullValuesPercentage: "20"
labels:
severity: info
8 changes: 7 additions & 1 deletion controllers/prometheusrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,14 @@ func prometheusInnerRuleToCoralogixAlert(prometheusRule prometheus.Rule) coralog
timeWindow = prometheusAlertForToCoralogixPromqlAlertTimeWindow["1m"]
}

severity := coralogixv1alpha1.AlertSeverityInfo
if severityStr, ok := prometheusRule.Labels["severity"]; ok {
severityStr = strings.ToUpper(severityStr[:1]) + severityStr[1:]
severity = coralogixv1alpha1.AlertSeverity(severityStr)
}

return coralogixv1alpha1.AlertSpec{
Severity: coralogixv1alpha1.AlertSeverityInfo,
Severity: severity,
NotificationGroups: []coralogixv1alpha1.NotificationGroup{
{
Notifications: []coralogixv1alpha1.Notification{
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/promatheusrules/00-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
for: 5m
annotations:
cxMinNonNullValuesPercentage: "20"
labels:
severity: critical
- name: example.rules2
interval: "70s"
rules:
Expand All @@ -29,4 +31,6 @@ spec:
expr: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) by (le, destination_workload)) > 0.2
for: 5m
annotations:
cxMinNonNullValuesPercentage: "20"
cxMinNonNullValuesPercentage: "20"
labels:
severity: info
2 changes: 1 addition & 1 deletion tests/e2e/promatheusrules/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ status:
- notifications:
- notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5
severity: Info
severity: Critical
showInInsight:
notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5

0 comments on commit d63821f

Please sign in to comment.