From 861fba4e3e881abdc2d4f6fbe06c71b962f969cc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 2 Oct 2024 22:30:26 +0000 Subject: [PATCH] add logging for remote monitor execution flows (#1663) Signed-off-by: Surya Sashank Nistala (cherry picked from commit ba3e7155172d4016669e17b7b54d66d0bb977ade) Signed-off-by: github-actions[bot] --- .../kotlin/org/opensearch/alerting/MonitorRunnerService.kt | 2 ++ .../transport/TransportDocLevelMonitorFanOutAction.kt | 6 +++++- .../org/opensearch/alerting/spi/RemoteMonitorRunner.kt | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunnerService.kt b/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunnerService.kt index cecd92269..ec8d57736 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunnerService.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunnerService.kt @@ -480,6 +480,7 @@ object MonitorRunnerService : JobRunner, CoroutineScope, AbstractLifecycleCompon } else { if (monitorCtx.remoteMonitors.containsKey(monitor.monitorType)) { if (monitor.monitorType.endsWith(Monitor.MonitorType.DOC_LEVEL_MONITOR.value)) { + logger.info("Executing remote document monitor of type ${monitor.monitorType} id ${monitor.id}") return RemoteDocumentLevelMonitorRunner().runMonitor( monitor, monitorCtx, @@ -490,6 +491,7 @@ object MonitorRunnerService : JobRunner, CoroutineScope, AbstractLifecycleCompon transportService = transportService ) } else { + logger.info("Executing remote monitor of type ${monitor.monitorType} id ${monitor.id}") return monitorCtx.remoteMonitors[monitor.monitorType]!!.monitorRunner.runMonitor( monitor, periodStart, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDocLevelMonitorFanOutAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDocLevelMonitorFanOutAction.kt index 4f24fe2d1..bfc55fa04 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDocLevelMonitorFanOutAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDocLevelMonitorFanOutAction.kt @@ -339,7 +339,11 @@ class TransportDocLevelMonitorFanOutAction ) ) } catch (e: Exception) { - log.error("${request.monitor.id} Failed to run fan_out on node ${clusterService.localNode().id} due to error $e") + log.error( + "${request.monitor.id} Failed to run fan_out on node ${clusterService.localNode().id}." + + " for Monitor Type ${request.monitor.monitorType} ExecutionId ${request.executionId}", + e + ) listener.onFailure(AlertingException.wrap(e)) } } diff --git a/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt b/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt index a2ceac7ba..becb25f92 100644 --- a/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt +++ b/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt @@ -49,7 +49,7 @@ open class RemoteMonitorRunner { } open fun getFanOutAction(): String { - return DocLevelMonitorFanOutAction.NAME + throw UnsupportedOperationException("Fan out action needs to be implemented by remote monitor."); } open suspend fun doFanOut( @@ -185,4 +185,4 @@ open class RemoteMonitorRunner { } } } -} \ No newline at end of file +}