@@ -301,7 +301,7 @@ class TransportDocLevelMonitorFanOutAction
301
301
* if should_persist_findings_and_alerts flag is not set, doc-level trigger generates alerts else doc-level trigger
302
302
* generates a single alert with multiple findings.
303
303
*/
304
- if (monitor.shouldPersistFindingsAndAlerts == null || monitor.shouldPersistFindingsAndAlerts == false ) {
304
+ if (monitor.shouldCreateSingleAlertForFindings == null || monitor.shouldCreateSingleAlertForFindings == false ) {
305
305
monitor.triggers.forEach {
306
306
triggerResults[it.id] = runForEachDocTrigger(
307
307
monitorResult,
@@ -316,9 +316,9 @@ class TransportDocLevelMonitorFanOutAction
316
316
workflowRunContext = workflowRunContext
317
317
)
318
318
}
319
- } else if (monitor.shouldPersistFindingsAndAlerts == true ) {
319
+ } else if (monitor.shouldCreateSingleAlertForFindings == true ) {
320
320
monitor.triggers.forEach {
321
- triggerResults[it.id] = runForEachDocTriggerWithoutPersistFindingsAndAlerts (
321
+ triggerResults[it.id] = runForEachDocTriggerCreateSingleGroupedAlert (
322
322
monitorResult,
323
323
it as DocumentLevelTrigger ,
324
324
monitor,
@@ -370,7 +370,7 @@ class TransportDocLevelMonitorFanOutAction
370
370
/* *
371
371
* run doc-level triggers ignoring findings and alerts and generating a single alert.
372
372
*/
373
- private suspend fun runForEachDocTriggerWithoutPersistFindingsAndAlerts (
373
+ private suspend fun runForEachDocTriggerCreateSingleGroupedAlert (
374
374
monitorResult : MonitorRunResult <DocumentLevelTriggerRunResult >,
375
375
trigger : DocumentLevelTrigger ,
376
376
monitor : Monitor ,
@@ -381,14 +381,14 @@ class TransportDocLevelMonitorFanOutAction
381
381
): DocumentLevelTriggerRunResult {
382
382
val triggerResult = triggerService.runDocLevelTrigger(monitor, trigger, queryToDocIds)
383
383
if (triggerResult.triggeredDocs.isNotEmpty()) {
384
- val findingIds = if (workflowRunContext?.matchingDocIdsPerIndex?.second != null ) {
385
- workflowRunContext.matchingDocIdsPerIndex.second
384
+ val findingIds = if (workflowRunContext?.findingIds != null ) {
385
+ workflowRunContext.findingIds
386
386
} else {
387
387
listOf ()
388
388
}
389
389
val triggerCtx = DocumentLevelTriggerExecutionContext (monitor, trigger)
390
390
val alert = alertService.composeDocLevelAlert(
391
- findingIds,
391
+ findingIds!! ,
392
392
triggerResult.triggeredDocs,
393
393
triggerCtx,
394
394
monitorResult.alertError() ? : triggerResult.alertError(),
@@ -582,7 +582,11 @@ class TransportDocLevelMonitorFanOutAction
582
582
.string()
583
583
log.debug(" Findings: $findingStr " )
584
584
585
- if (shouldCreateFinding and (monitor.shouldPersistFindingsAndAlerts == null || monitor.shouldPersistFindingsAndAlerts == false )) {
585
+ if (shouldCreateFinding and (
586
+ monitor.shouldCreateSingleAlertForFindings == null ||
587
+ monitor.shouldCreateSingleAlertForFindings == false
588
+ )
589
+ ) {
586
590
indexRequests + = IndexRequest (monitor.dataSources.findingsIndex)
587
591
.source(findingStr, XContentType .JSON )
588
592
.id(finding.id)
@@ -594,7 +598,7 @@ class TransportDocLevelMonitorFanOutAction
594
598
bulkIndexFindings(monitor, indexRequests)
595
599
}
596
600
597
- if (monitor.shouldPersistFindingsAndAlerts == null || monitor.shouldPersistFindingsAndAlerts == false ) {
601
+ if (monitor.shouldCreateSingleAlertForFindings == null || monitor.shouldCreateSingleAlertForFindings == false ) {
598
602
try {
599
603
findings.forEach { finding ->
600
604
publishFinding(monitor, finding)
@@ -957,11 +961,11 @@ class TransportDocLevelMonitorFanOutAction
957
961
val boolQueryBuilder = BoolQueryBuilder ()
958
962
boolQueryBuilder.filter(QueryBuilders .rangeQuery(" _seq_no" ).gt(prevSeqNo).lte(maxSeqNo))
959
963
960
- if (monitor.shouldPersistFindingsAndAlerts == null || monitor.shouldPersistFindingsAndAlerts == false ) {
964
+ if (monitor.shouldCreateSingleAlertForFindings == null || monitor.shouldCreateSingleAlertForFindings == false ) {
961
965
if (! docIds.isNullOrEmpty()) {
962
966
boolQueryBuilder.filter(QueryBuilders .termsQuery(" _id" , docIds))
963
967
}
964
- } else if (monitor.shouldPersistFindingsAndAlerts == true ) {
968
+ } else if (monitor.shouldCreateSingleAlertForFindings == true ) {
965
969
val docIdsParam = mutableListOf<String >()
966
970
if (docIds != null ) {
967
971
docIdsParam.addAll(docIds)
0 commit comments