Skip to content

Commit

Permalink
Update MonitorRunner.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Annie Lee committed Mar 18, 2022
1 parent d20be8c commit 7892da0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7892da0

Please sign in to comment.