From 7892da03e67f9479ecdb2319a886adeddbb26b2b Mon Sep 17 00:00:00 2001 From: Annie Lee Date: Fri, 18 Mar 2022 11:48:45 -0700 Subject: [PATCH] Update MonitorRunner.kt --- .../src/main/kotlin/org/opensearch/alerting/MonitorRunner.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunner.kt b/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunner.kt index 972bcbcfd..3ad919fce 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunner.kt @@ -830,14 +830,14 @@ object MonitorRunner : JobRunner, CoroutineScope, AbstractLifecycleComponent() { triggerName = trigger.name ) - val findingStr = finding.toXContent(XContentBuilder.builder(XContentType.JSON.xContent()), ToXContent.EMPTY_PARAMS).string() + val findingStr = finding.toXContent(XContentFactory.jsonBuilder(), ToXContent.MapParams(mapOf("with_type" to "true"))) // change this to debug. logger.info("Findings: $findingStr") // todo: below is all hardcoded, temp code and added only to test. replace this with proper Findings index lifecycle management. val indexRequest = IndexRequest(".opensearch-alerting-findings") .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) - .source(finding.toXContent(XContentFactory.jsonBuilder(), ToXContent.MapParams(mapOf("with_type" to "true")))) + .source(findingStr, XContentType.JSON) client.index(indexRequest).actionGet() return finding.id