Skip to content

Commit

Permalink
support setting integration name for alert (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Marston <alexander.marston@imaginecurve.com>
  • Loading branch information
alexandermarston authored Oct 22, 2024
1 parent cb87680 commit 6e4097a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/prometheusrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -305,6 +306,7 @@ func prometheusRuleToCoralogixAlertSpec(rule prometheus.Rule) coralogixv1alpha1.
Notifications: []coralogixv1alpha1.Notification{
{
RetriggeringPeriodMinutes: getNotificationPeriod(rule),
IntegrationName: getNotificationIntegrationName(rule),
},
},
},
Expand Down Expand Up @@ -363,6 +365,14 @@ func getNotificationPeriod(rule prometheus.Rule) int32 {
return defaultCoralogixNotificationPeriod
}

func getNotificationIntegrationName(rule prometheus.Rule) *string {
if integrationName, ok := rule.Annotations["cxNotificationName"]; ok {
return pointer.String(integrationName)
}

return nil
}

var prometheusAlertForToCoralogixPromqlAlertTimeWindow = map[prometheus.Duration]coralogixv1alpha1.MetricTimeWindow{
"1m": coralogixv1alpha1.MetricTimeWindow(coralogixv1alpha1.TimeWindowMinute),
"5m": coralogixv1alpha1.MetricTimeWindow(coralogixv1alpha1.TimeWindowFiveMinutes),
Expand Down

0 comments on commit 6e4097a

Please sign in to comment.