diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt index b34541a62..c127381b9 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt @@ -324,8 +324,11 @@ object DocumentLevelMonitorRunner : MonitorRunner() { } override fun onFailure(e: Exception) { - logger.info("Fan out failed") - cont.resumeWithException(e) + logger.info("Fan out failed", e) + if (e.cause is Exception) // unwrap remote transport exception + cont.resumeWithException(e.cause as Exception) + else + cont.resumeWithException(e) } }, nodeMap.size diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt index 7eee2dadf..f86625082 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt @@ -645,7 +645,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { .get() Assert.assertTrue(getAlertsResponse != null) Assert.assertTrue(getAlertsResponse.alerts.size == 1) - Assert.assertTrue(getAlertsResponse.alerts[0].errorMessage == "IndexClosedException[closed]") + Assert.assertTrue(getAlertsResponse.alerts[0].errorMessage!!.contains("IndexClosedException[closed]")) // Reopen index client().admin().indices().open(OpenIndexRequest(index)).get() // Close queryIndex