From 68383352762217cddc2a26c6a4b2891d445c029f Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Mon, 10 Oct 2022 13:05:26 -0700 Subject: [PATCH] port over datasources alert index usage correctly Signed-off-by: Surya Sashank Nistala --- .../main/kotlin/org/opensearch/alerting/AlertService.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt b/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt index 067b48cf7..2bc433dd4 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt @@ -293,7 +293,7 @@ class AlertService( when (alert.state) { Alert.State.ACTIVE, Alert.State.ERROR -> { listOf>( - IndexRequest(AlertIndices.ALERT_INDEX) + IndexRequest(alertIndex) .routing(alert.monitorId) .source(alert.toXContentWithUser(XContentFactory.jsonBuilder())) .id(if (alert.id != Alert.NO_ID) alert.id else null) @@ -304,7 +304,7 @@ class AlertService( // and updated by the MonitorRunner if (allowUpdatingAcknowledgedAlert) { listOf>( - IndexRequest(AlertIndices.ALERT_INDEX) + IndexRequest(alertIndex) .routing(alert.monitorId) .source(alert.toXContentWithUser(XContentFactory.jsonBuilder())) .id(if (alert.id != Alert.NO_ID) alert.id else null) @@ -318,7 +318,7 @@ class AlertService( } Alert.State.COMPLETED -> { listOfNotNull>( - DeleteRequest(AlertIndices.ALERT_INDEX, alert.id) + DeleteRequest(alertIndex, alert.id) .routing(alert.monitorId), // Only add completed alert to history index if history is enabled if (alertIndices.isAlertHistoryEnabled(dataSources)) { @@ -366,7 +366,7 @@ class AlertService( if (alert.id != Alert.NO_ID) { throw IllegalStateException("Unexpected attempt to save new alert [$alert] with an existing alert ID [${alert.id}]") } - IndexRequest(AlertIndices.ALERT_INDEX) + IndexRequest(dataSources.alertsIndex) .routing(alert.monitorId) .source(alert.toXContentWithUser(XContentFactory.jsonBuilder())) }.toMutableList()