From 62d252483c794475b06d31ba21f90a9419101f4e Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Thu, 22 Jun 2023 16:06:52 -0700 Subject: [PATCH] add workflow_id field in alert mapping (#969) Signed-off-by: Surya Sashank Nistala --- .../main/kotlin/org/opensearch/alerting/AlertService.kt | 8 ++++++++ .../org/opensearch/alerting/alerts/alert_mapping.json | 3 +++ 2 files changed, 11 insertions(+) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt b/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt index a86c1a710..f2d07a102 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt @@ -542,6 +542,14 @@ class AlertService( throw IllegalStateException("Unexpected attempt to save ${alert.state} alert: $alert") } } + Alert.State.AUDIT -> { + listOf>( + IndexRequest(alertsIndex) + .routing(alert.monitorId) + .source(alert.toXContentWithUser(XContentFactory.jsonBuilder())) + .id(if (alert.id != Alert.NO_ID) alert.id else null) + ) + } Alert.State.DELETED -> { throw IllegalStateException("Unexpected attempt to save ${alert.state} alert: $alert") } diff --git a/alerting/src/main/resources/org/opensearch/alerting/alerts/alert_mapping.json b/alerting/src/main/resources/org/opensearch/alerting/alerts/alert_mapping.json index 4cc60f233..acabec7e0 100644 --- a/alerting/src/main/resources/org/opensearch/alerting/alerts/alert_mapping.json +++ b/alerting/src/main/resources/org/opensearch/alerting/alerts/alert_mapping.json @@ -13,6 +13,9 @@ "monitor_id": { "type": "keyword" }, + "workflow_id": { + "type": "keyword" + }, "monitor_version": { "type": "long" },