From ba3e7155172d4016669e17b7b54d66d0bb977ade Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Wed, 2 Oct 2024 15:30:01 -0700 Subject: [PATCH] add logging for remote monitor execution flows (#1663) Signed-off-by: Surya Sashank Nistala --- .../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 68a4834f2..60fe2b684 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDocLevelMonitorFanOutAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDocLevelMonitorFanOutAction.kt @@ -340,7 +340,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 +}