From b1182e156b5373f81084b1fedd2bf1ea82d8fd4c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 2 May 2024 16:53:20 +0000 Subject: [PATCH] fix fieldLimit exception in docLevelMonitor (#1368) * fix fieldLimit exception in docLevelMonitor Signed-off-by: Riya Saxena * bug fixes from prev pr Signed-off-by: Riya Saxena --------- Signed-off-by: Riya Saxena (cherry picked from commit 77fc8b6ff845b99cc926bf8c324992495a109c37) Signed-off-by: github-actions[bot] --- .../alerting/DocumentLevelMonitorRunner.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt index 4005a8cc0..cc15ad71a 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt @@ -75,8 +75,16 @@ class DocumentLevelMonitorRunner : MonitorRunner() { monitorCtx.alertIndices!!.createOrUpdateInitialFindingHistoryIndex(monitor.dataSources) } catch (e: Exception) { val id = if (monitor.id.trim().isEmpty()) "_na_" else monitor.id - logger.error("Error setting up alerts and findings indices for monitor: $id", e) - monitorResult = monitorResult.copy(error = AlertingException.wrap(e)) + val unwrappedException = ExceptionsHelper.unwrapCause(e) + if (unwrappedException is IllegalArgumentException && unwrappedException.message?.contains("Limit of total fields") == true) { + val errorMessage = + "Monitor [$id] can't process index [$monitor.dataSources] due to field mapping limit" + logger.error("Exception: ${unwrappedException.message}") + monitorResult = monitorResult.copy(error = AlertingException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR, e)) + } else { + logger.error("Error setting up alerts and findings indices for monitor: $id", e) + monitorResult = monitorResult.copy(error = AlertingException.wrap(e)) + } } try { validate(monitor)