diff --git a/config/samples/alertmanger/example-alertmanager.yaml b/config/samples/alertmanager/example-alertmanager.yaml similarity index 90% rename from config/samples/alertmanger/example-alertmanager.yaml rename to config/samples/alertmanager/example-alertmanager.yaml index 3dc1ac8..cd1c034 100644 --- a/config/samples/alertmanger/example-alertmanager.yaml +++ b/config/samples/alertmanager/example-alertmanager.yaml @@ -40,9 +40,11 @@ spec: key: "webhook-url" # Key in the Kubernetes Secret - name: opsgenie-general opsgenieConfigs: - - apiURL: https://api.opsgenie.com/v2/alerts + - sendResolved: true + apiURL: https://api.opsgenie.com/v2/alerts - name: slack-default slackConfigs: - - apiURL: + - sendResolved: false + apiURL: name: "slack-webhook-secret" # Name of the Kubernetes Secret key: "webhook-url" # Key in the Kubernetes Secret \ No newline at end of file diff --git a/config/samples/alertmanger/slack-url-secret.yaml b/config/samples/alertmanager/slack-url-secret.yaml similarity index 100% rename from config/samples/alertmanger/slack-url-secret.yaml rename to config/samples/alertmanager/slack-url-secret.yaml diff --git a/controllers/alertmanagerconfig_controller.go b/controllers/alertmanagerconfig_controller.go index f1645db..d40ce40 100644 --- a/controllers/alertmanagerconfig_controller.go +++ b/controllers/alertmanagerconfig_controller.go @@ -286,9 +286,9 @@ func matchedRoutesToMatchedReceiversMap(matchedRoutes []*prometheus.Route, allRe return matchedReceiversMap } -func generateNotificationGroupFromRoutes(matchedRouts []*prometheus.Route, matchedReceivers map[string]*prometheus.Receiver) ([]coralogixv1alpha1.NotificationGroup, error) { +func generateNotificationGroupFromRoutes(matchedRoutes []*prometheus.Route, matchedReceivers map[string]*prometheus.Receiver) ([]coralogixv1alpha1.NotificationGroup, error) { var notificationsGroups []coralogixv1alpha1.NotificationGroup - for _, route := range matchedRouts { + for _, route := range matchedRoutes { receiver, ok := matchedReceivers[route.Receiver] if !ok || receiver == nil { continue @@ -304,13 +304,13 @@ func generateNotificationGroupFromRoutes(matchedRouts []*prometheus.Route, match Notifications: []coralogixv1alpha1.Notification{}, } - for i := range receiver.SlackConfigs { + for i, conf := range receiver.SlackConfigs { webhookName := fmt.Sprintf("%s.%s.%d", receiver.Name, "slack", i) - notificationsGroup.Notifications = append(notificationsGroup.Notifications, webhookNameToAlertNotification(webhookName, retriggeringPeriodMinutes)) + notificationsGroup.Notifications = append(notificationsGroup.Notifications, webhookNameToAlertNotification(webhookName, retriggeringPeriodMinutes, conf.SendResolved)) } - for i := range receiver.OpsGenieConfigs { + for i, conf := range receiver.OpsGenieConfigs { webhookName := fmt.Sprintf("%s.%s.%d", receiver.Name, "opsgenie", i) - notificationsGroup.Notifications = append(notificationsGroup.Notifications, webhookNameToAlertNotification(webhookName, retriggeringPeriodMinutes)) + notificationsGroup.Notifications = append(notificationsGroup.Notifications, webhookNameToAlertNotification(webhookName, retriggeringPeriodMinutes, conf.SendResolved)) } notificationsGroups = append(notificationsGroups, notificationsGroup) @@ -331,10 +331,17 @@ func getRetriggeringPeriodMinutes(route *prometheus.Route) (int32, error) { return retriggeringPeriodMinutes, nil } -func webhookNameToAlertNotification(webhookName string, retriggeringPeriodMinutes int32) coralogixv1alpha1.Notification { +func webhookNameToAlertNotification(webhookName string, retriggeringPeriodMinutes int32, notifyOnResolve *bool) coralogixv1alpha1.Notification { + var notifyOn string + if notifyOnResolve != nil && *notifyOnResolve { + notifyOn = coralogixv1alpha1.NotifyOnTriggeredAndResolved + } else { + notifyOn = coralogixv1alpha1.NotifyOnTriggeredOnly + } return coralogixv1alpha1.Notification{ IntegrationName: pointer.String(webhookName), RetriggeringPeriodMinutes: retriggeringPeriodMinutes, + NotifyOn: coralogixv1alpha1.NotifyOn(notifyOn), } } diff --git a/kuttl-test.yaml b/kuttl-test.yaml index 3584672..1bd8c2f 100644 --- a/kuttl-test.yaml +++ b/kuttl-test.yaml @@ -4,7 +4,7 @@ testDirs: - tests/e2e/alerts - tests/e2e/rulegroups - tests/e2e/recordingrulegroupsets - - tests/e2e/promatheusrules + - tests/e2e/prometheusrules - tests/e2e/outboundwebhooks - tests/e2e/alertmangerconfigs namespace: default diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/00-assert.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/00-assert.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/00-assert.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/00-assert.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/00-install.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/00-install.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/00-install.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/00-install.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/01-assert.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/01-assert.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/01-assert.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/01-assert.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/02-assert.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/02-assert.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/02-assert.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/02-assert.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/03-assert.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/03-assert.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/03-assert.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/03-assert.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/03-install.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/03-install.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/03-install.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/03-install.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/04-assert.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/04-assert.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/04-assert.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/04-assert.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/05-assert.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/05-assert.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/05-assert.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/05-assert.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/05-delete.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/05-delete.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/05-delete.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/05-delete.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/06-delete.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/06-delete.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/06-delete.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/06-delete.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/07-delete.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/07-delete.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/07-delete.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/07-delete.yaml diff --git a/tests/e2e/promatheusrules/promatheusrules-basic/08-delete.yaml b/tests/e2e/prometheusrules/prometheusrules-basic/08-delete.yaml similarity index 100% rename from tests/e2e/promatheusrules/promatheusrules-basic/08-delete.yaml rename to tests/e2e/prometheusrules/prometheusrules-basic/08-delete.yaml