From a5cd62a0e2a936a790d043292f5cf154d8a31441 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 7 Mar 2024 17:13:35 +0100 Subject: [PATCH] Add option to set custom driver log url with pattern replacement --- .../scala/org/apache/spark/internal/config/UI.scala | 12 ++++++++++++ .../cluster/CoarseGrainedSchedulerBackend.scala | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/core/src/main/scala/org/apache/spark/internal/config/UI.scala b/core/src/main/scala/org/apache/spark/internal/config/UI.scala index c4c5796a2b278..4e36a2b8769b6 100644 --- a/core/src/main/scala/org/apache/spark/internal/config/UI.scala +++ b/core/src/main/scala/org/apache/spark/internal/config/UI.scala @@ -220,6 +220,18 @@ private[spark] object UI { .stringConf .createOptional + val CUSTOM_DRIVER_LOG_URL = ConfigBuilder("spark.ui.custom.driver.log.url") + .doc("Specifies custom spark driver log url for supporting external log service instead of " + + "using cluster managers' application log urls in the Spark UI. Spark will support " + + "some path variables via patterns which can vary on cluster manager. Please check the " + + "documentation for your cluster manager to see which patterns are supported, if any. " + + "This configuration replaces original log urls in event log, which will be also effective " + + "when accessing the application on history server. The new log urls must be permanent, " + + "otherwise you might have dead link for executor log urls.") + .version("4.0.0") + .stringConf + .createOptional + val CUSTOM_EXECUTOR_LOG_URL = ConfigBuilder("spark.ui.custom.executor.log.url") .doc("Specifies custom spark executor log url for supporting external log service instead of " + "using cluster managers' application log urls in the Spark UI. Spark will support " + diff --git a/core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala b/core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala index 7e124302c726d..78bbf73ecaa33 100644 --- a/core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala +++ b/core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala @@ -141,6 +141,11 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp ThreadUtils.newDaemonSingleThreadScheduledExecutor("cleanup-decommission-execs") } + override def getDriverLogUrls: Option[Map[String, String]] = { + val logUrlHandler = new ExecutorLogUrlHandler(conf.get(UI.CUSTOM_DRIVER_LOG_URL)) + getDriverAttributes.map(attr => logUrlHandler.applyPattern(Map.empty, attr)).filter(_.nonEmpty) + } + class DriverEndpoint extends IsolatedThreadSafeRpcEndpoint with Logging { override val rpcEnv: RpcEnv = CoarseGrainedSchedulerBackend.this.rpcEnv