Skip to content

Commit 17f1695

Browse files
committed
populate results in document level trigger execution context
Signed-off-by: Surya Sashank Nistala <[email protected]>
1 parent 9f3c393 commit 17f1695

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ object DocumentLevelMonitorRunner : MonitorRunner() {
222222
queryToDocIds: Map<DocLevelQuery, Set<String>>,
223223
dryrun: Boolean
224224
): DocumentLevelTriggerRunResult {
225-
val triggerCtx = DocumentLevelTriggerExecutionContext(monitor, trigger)
225+
val triggerCtx = DocumentLevelTriggerExecutionContext(monitor, trigger, monitorResult)
226226
val triggerResult = monitorCtx.triggerService!!.runDocLevelTrigger(monitor, trigger, queryToDocIds)
227227

228228
val findings = mutableListOf<String>()

alerting/src/main/kotlin/org/opensearch/alerting/script/DocumentLevelTriggerExecutionContext.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package org.opensearch.alerting.script
88
import org.opensearch.alerting.model.Alert
99
import org.opensearch.alerting.model.DocumentLevelTrigger
1010
import org.opensearch.alerting.model.Monitor
11+
import org.opensearch.alerting.model.MonitorRunResult
12+
import org.opensearch.alerting.model.DocumentLevelTriggerRunResult
1113
import java.time.Instant
1214

1315
data class DocumentLevelTriggerExecutionContext(
@@ -25,10 +27,11 @@ data class DocumentLevelTriggerExecutionContext(
2527
constructor(
2628
monitor: Monitor,
2729
trigger: DocumentLevelTrigger,
30+
monitorRunResult: MonitorRunResult<DocumentLevelTriggerRunResult>,
2831
alerts: List<Alert> = listOf()
2932
) : this(
30-
monitor, trigger, emptyList(), Instant.now(), Instant.now(),
31-
alerts, emptyList(), emptyList(), null
33+
monitor, trigger, monitorRunResult.inputResults.results, monitorRunResult.periodStart, monitorRunResult.periodEnd,
34+
alerts, emptyList(), emptyList(), monitorRunResult.scriptContextError(trigger)
3235
)
3336

3437
/**

0 commit comments

Comments
 (0)