diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt b/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt index adbb50aa3..09a4c61b5 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/AlertService.kt @@ -347,7 +347,7 @@ class AlertService( else Alert.State.ERROR Alert( startTime = Instant.now(), - lastNotificationTime = Instant.now(), + lastNotificationTime = currentTime, state = Alert.State.ACTIVE, errorMessage = null, schemaVersion = -1, chainedAlertTrigger = ctx.trigger, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/script/ChainedAlertTriggerExecutionContext.kt b/alerting/src/main/kotlin/org/opensearch/alerting/script/ChainedAlertTriggerExecutionContext.kt index a05b8c4bc..d4bf4cb59 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/script/ChainedAlertTriggerExecutionContext.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/script/ChainedAlertTriggerExecutionContext.kt @@ -23,26 +23,6 @@ data class ChainedAlertTriggerExecutionContext( val alert: Alert? = null ) { - constructor( - workflow: Workflow, - workflowRunResult: WorkflowRunResult, - trigger: ChainedAlertTrigger, - alertGeneratingMonitors: Set, - monitorIdToAlertIdsMap: Map>, - alert: Alert? = null - ) : - this( - workflow, - workflowRunResult, - workflowRunResult.executionStartTime, - workflowRunResult.executionEndTime, - workflowRunResult.error, - trigger, - alertGeneratingMonitors, - monitorIdToAlertIdsMap, - alert - ) - /** * Mustache templates need special permissions to reflectively introspect field names. To avoid doing this we * translate the context to a Map of Strings to primitive types, which can be accessed without reflection. diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/workflow/CompositeWorkflowRunner.kt b/alerting/src/main/kotlin/org/opensearch/alerting/workflow/CompositeWorkflowRunner.kt index ffbdce821..bc9ac98dc 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/workflow/CompositeWorkflowRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/workflow/CompositeWorkflowRunner.kt @@ -171,6 +171,8 @@ object CompositeWorkflowRunner : WorkflowRunner() { val triggerCtx = ChainedAlertTriggerExecutionContext( workflow = workflow, workflowRunResult = workflowRunResult, + periodStart = workflowRunResult.executionStartTime, + periodEnd = workflowRunResult.executionEndTime, trigger = caTrigger, alertGeneratingMonitors = monitorIdToAlertIdsMap.keys, monitorIdToAlertIdsMap = monitorIdToAlertIdsMap,