@@ -358,7 +358,8 @@ class DocLevelMonitorQueries(private val client: Client, private val clusterServ
358
358
monitorMetadata,
359
359
updatedIndexName,
360
360
sourceIndexFieldLimit,
361
- updatedProperties
361
+ updatedProperties,
362
+ indexTimeout
362
363
)
363
364
364
365
if (updateMappingResponse.isAcknowledged) {
@@ -487,7 +488,8 @@ class DocLevelMonitorQueries(private val client: Client, private val clusterServ
487
488
monitorMetadata : MonitorMetadata ,
488
489
sourceIndex : String ,
489
490
sourceIndexFieldLimit : Long ,
490
- updatedProperties : MutableMap <String , Any >
491
+ updatedProperties : MutableMap <String , Any >,
492
+ indexTimeout : TimeValue
491
493
): Pair <AcknowledgedResponse , String > {
492
494
var targetQueryIndex = monitorMetadata.sourceToQueryIndexMapping[sourceIndex + monitor.id]
493
495
if (
@@ -551,9 +553,48 @@ class DocLevelMonitorQueries(private val client: Client, private val clusterServ
551
553
}
552
554
}
553
555
} else {
554
- log.debug(" unknown exception during PUT mapping on queryIndex: $targetQueryIndex " )
555
- val unwrappedException = ExceptionsHelper .unwrapCause(e) as Exception
556
- throw AlertingException .wrap(unwrappedException)
556
+ // retry with deleting query index
557
+ if (monitor.deleteQueryIndexInEveryRun == true ) {
558
+ try {
559
+ log.error(
560
+ " unknown exception during PUT mapping on queryIndex: $targetQueryIndex , " +
561
+ " retrying with deletion of query index" ,
562
+ e
563
+ )
564
+ if (docLevelQueryIndexExists(monitor.dataSources)) {
565
+ val ack = monitorCtx.docLevelMonitorQueries!! .deleteDocLevelQueryIndex(monitor.dataSources)
566
+ if (! ack) {
567
+ log.error(
568
+ " Deletion of concrete queryIndex:${monitor.dataSources.queryIndex} is not ack'd! " +
569
+ " for monitor ${monitor.id} "
570
+ )
571
+ }
572
+ }
573
+ initDocLevelQueryIndex(monitor.dataSources)
574
+ indexDocLevelQueries(
575
+ monitor = monitor,
576
+ monitorId = monitor.id,
577
+ monitorMetadata,
578
+ indexTimeout = indexTimeout
579
+ )
580
+ } catch (e: Exception ) {
581
+ log.error(
582
+ " Doc level monitor ${monitor.id} : unknown exception during " +
583
+ " PUT mapping on queryIndex: $targetQueryIndex " ,
584
+ e
585
+ )
586
+ val unwrappedException = ExceptionsHelper .unwrapCause(e) as Exception
587
+ throw AlertingException .wrap(unwrappedException)
588
+ }
589
+ } else {
590
+ log.error(
591
+ " Doc level monitor ${monitor.id} : unknown exception during " +
592
+ " PUT mapping on queryIndex: $targetQueryIndex " ,
593
+ e
594
+ )
595
+ val unwrappedException = ExceptionsHelper .unwrapCause(e) as Exception
596
+ throw AlertingException .wrap(unwrappedException)
597
+ }
557
598
}
558
599
}
559
600
// We did rollover, so try to apply mappings again on new targetQueryIndex
0 commit comments