Skip to content

Commit 6e4097a

Browse files
support setting integration name for alert (#167)
Signed-off-by: Alex Marston <alexander.marston@imaginecurve.com>
1 parent cb87680 commit 6e4097a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

controllers/prometheusrule_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"k8s.io/apimachinery/pkg/api/resource"
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
"k8s.io/apimachinery/pkg/runtime"
20+
"k8s.io/utils/pointer"
2021
"k8s.io/utils/ptr"
2122
ctrl "sigs.k8s.io/controller-runtime"
2223
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -305,6 +306,7 @@ func prometheusRuleToCoralogixAlertSpec(rule prometheus.Rule) coralogixv1alpha1.
305306
Notifications: []coralogixv1alpha1.Notification{
306307
{
307308
RetriggeringPeriodMinutes: getNotificationPeriod(rule),
309+
IntegrationName: getNotificationIntegrationName(rule),
308310
},
309311
},
310312
},
@@ -363,6 +365,14 @@ func getNotificationPeriod(rule prometheus.Rule) int32 {
363365
return defaultCoralogixNotificationPeriod
364366
}
365367

368+
func getNotificationIntegrationName(rule prometheus.Rule) *string {
369+
if integrationName, ok := rule.Annotations["cxNotificationName"]; ok {
370+
return pointer.String(integrationName)
371+
}
372+
373+
return nil
374+
}
375+
366376
var prometheusAlertForToCoralogixPromqlAlertTimeWindow = map[prometheus.Duration]coralogixv1alpha1.MetricTimeWindow{
367377
"1m": coralogixv1alpha1.MetricTimeWindow(coralogixv1alpha1.TimeWindowMinute),
368378
"5m": coralogixv1alpha1.MetricTimeWindow(coralogixv1alpha1.TimeWindowFiveMinutes),

0 commit comments

Comments
 (0)