From cc6d5b32d72cf572b216f337004509dc9dcf180e Mon Sep 17 00:00:00 2001 From: Riya Saxena Date: Fri, 5 Jan 2024 16:44:54 -0800 Subject: [PATCH 1/2] fix fieldLimit exception in docLevelMonitor Signed-off-by: Riya Saxena --- .../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 3b8e4dee7..0cf0f0e18 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt @@ -87,8 +87,16 @@ object 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) as Exception + 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(errorMessage) + 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 { From 897ebbdff58339027fd8707d79a8f44a0005c2f8 Mon Sep 17 00:00:00 2001 From: Riya Saxena Date: Wed, 10 Jan 2024 10:36:16 -0800 Subject: [PATCH 2/2] bug fixes from prev pr Signed-off-by: Riya Saxena --- .../org/opensearch/alerting/DocumentLevelMonitorRunner.kt | 4 ++-- 1 file changed, 2 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 0cf0f0e18..3f3af8351 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt @@ -87,11 +87,11 @@ object DocumentLevelMonitorRunner : MonitorRunner() { monitorCtx.alertIndices!!.createOrUpdateInitialFindingHistoryIndex(monitor.dataSources) } catch (e: Exception) { val id = if (monitor.id.trim().isEmpty()) "_na_" else monitor.id - val unwrappedException = ExceptionsHelper.unwrapCause(e) as Exception + 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(errorMessage) + 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)