Skip to content

Commit 77fc8b6

Browse files
fix fieldLimit exception in docLevelMonitor (opensearch-project#1368)
* fix fieldLimit exception in docLevelMonitor Signed-off-by: Riya Saxena <[email protected]> * bug fixes from prev pr Signed-off-by: Riya Saxena <[email protected]> --------- Signed-off-by: Riya Saxena <[email protected]>
1 parent d2a590e commit 77fc8b6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,16 @@ class DocumentLevelMonitorRunner : MonitorRunner() {
115115
monitorCtx.alertIndices!!.createOrUpdateInitialFindingHistoryIndex(monitor.dataSources)
116116
} catch (e: Exception) {
117117
val id = if (monitor.id.trim().isEmpty()) "_na_" else monitor.id
118-
logger.error("Error setting up alerts and findings indices for monitor: $id", e)
119-
monitorResult = monitorResult.copy(error = AlertingException.wrap(e))
118+
val unwrappedException = ExceptionsHelper.unwrapCause(e)
119+
if (unwrappedException is IllegalArgumentException && unwrappedException.message?.contains("Limit of total fields") == true) {
120+
val errorMessage =
121+
"Monitor [$id] can't process index [$monitor.dataSources] due to field mapping limit"
122+
logger.error("Exception: ${unwrappedException.message}")
123+
monitorResult = monitorResult.copy(error = AlertingException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR, e))
124+
} else {
125+
logger.error("Error setting up alerts and findings indices for monitor: $id", e)
126+
monitorResult = monitorResult.copy(error = AlertingException.wrap(e))
127+
}
120128
}
121129
try {
122130
validate(monitor)

0 commit comments

Comments
 (0)