This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 85ea4f2  [SPARK-55344] Support `spark.kubernetes.operator.metrics.path`
85ea4f2 is described below

commit 85ea4f2caadb928a915b3e71097ab4e3d1fe158a
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Tue Feb 3 15:17:46 2026 -0800

    [SPARK-55344] Support `spark.kubernetes.operator.metrics.path`
    
    ### What changes were proposed in this pull request?
    
    This PR aims to support `spark.kubernetes.operator.metrics.path`.
    
    ### Why are the changes needed?
    
    This allows users to use a standard `/metrics` path in their installation 
instead of `Apache Spark`'s convention, `/prometheus`.
    ```
    spark.kubernetes.operator.metrics.path=/metrics
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Pass the CIs and manual tests.
    
    1. Setting like the following.
    
    ```
    build-tools/helm/spark-kubernetes-operator/values.yaml
     -201,6 +201,8  operatorConfiguration:
       spark-operator.properties: |+
         # Property Overrides. e.g.
         # spark.kubernetes.operator.reconciler.intervalSeconds=60
    +    spark.kubernetes.operator.metrics.path=/metrics
    +    spark.kubernetes.operator.metrics.port=9090
    ```
    
    2. After launching and port-forwarding the server, we can use like the 
following.
    
    ```
    $ curl http://localhost:9090/metrics/
    # HELP jvm_bufferpool_direct_capacity Gauge metric
    # TYPE jvm_bufferpool_direct_capacity gauge
    jvm_bufferpool_direct_capacity 0
    
    # HELP jvm_bufferpool_direct_count Gauge metric
    # TYPE jvm_bufferpool_direct_count gauge
    jvm_bufferpool_direct_count 1
    ...
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #483 from dongjoon-hyun/SPARK-55344.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 docs/config_properties.md                                      |  1 +
 .../apache/spark/k8s/operator/config/SparkOperatorConf.java    | 10 ++++++++++
 .../org/apache/spark/k8s/operator/metrics/MetricsService.java  |  7 ++++---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/docs/config_properties.md b/docs/config_properties.md
index 5462a08..6cbd373 100644
--- a/docs/config_properties.md
+++ b/docs/config_properties.md
@@ -20,6 +20,7 @@
  | spark.kubernetes.operator.metrics.clientMetricsEnabled | Boolean | true | 
false | Enable KubernetesClient metrics for measuring the HTTP traffic to the 
Kubernetes API Server. Since the metrics is collected via interceptors, can be 
disabled when opt in customized interceptors. | 
  | spark.kubernetes.operator.metrics.clientMetricsGroupByResponseCodeEnabled | 
Boolean | true | false | When enabled, additional metrics group by http 
response code group(1xx, 2xx, 3xx, 4xx, 5xx) received from API server will be 
added. Users can disable it when their monitoring system can combine lower 
level kubernetes.client.http.response.<3-digit-response-code> metrics. | 
  | spark.kubernetes.operator.metrics.josdkMetricsEnabled | Boolean | true | 
false | When enabled, the josdk metrics will be added in metrics source and 
configured for operator. | 
+ | spark.kubernetes.operator.metrics.path | String | /prometheus | false | The 
path used for checking metrics | 
  | spark.kubernetes.operator.metrics.port | Integer | 19090 | false | The port 
used for checking metrics | 
  | spark.kubernetes.operator.metrics.prometheusTextBasedFormatEnabled | 
Boolean | true | false | Whether or not to enable text-based format for 
Prometheus 2.0, as recommended by 
https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format 
| 
  | spark.kubernetes.operator.metrics.sanitizePrometheusMetricsNameEnabled | 
Boolean | true | false | Whether or not to enable automatic name sanitizing for 
all metrics based on best-practice guide from Prometheus 
https://prometheus.io/docs/practices/naming/ | 
diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConf.java
 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConf.java
index 5fdffb5..c72f355 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConf.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/config/SparkOperatorConf.java
@@ -435,6 +435,16 @@ public final class SparkOperatorConf {
               .defaultValue(true)
               .build();
 
+  /** The path used for checking metrics */
+  public static final ConfigOption<String> OPERATOR_METRICS_PATH =
+      ConfigOption.<String>builder()
+          .key("spark.kubernetes.operator.metrics.path")
+          .enableDynamicOverride(false)
+          .description("The path used for checking metrics")
+          .typeParameterClass(String.class)
+          .defaultValue("/prometheus")
+          .build();
+
   /** The port used for checking metrics */
   public static final ConfigOption<Integer> OPERATOR_METRICS_PORT =
       ConfigOption.<Integer>builder()
diff --git 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/MetricsService.java
 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/MetricsService.java
index c3024b5..1081e29 100644
--- 
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/MetricsService.java
+++ 
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/MetricsService.java
@@ -19,6 +19,7 @@
 
 package org.apache.spark.k8s.operator.metrics;
 
+import static 
org.apache.spark.k8s.operator.config.SparkOperatorConf.OPERATOR_METRICS_PATH;
 import static 
org.apache.spark.k8s.operator.config.SparkOperatorConf.OPERATOR_METRICS_PORT;
 
 import java.io.IOException;
@@ -30,7 +31,7 @@ import lombok.extern.slf4j.Slf4j;
 
 import org.apache.spark.k8s.operator.utils.HttpMethodFilter;
 
-/** Start Http service at endpoint /prometheus, exposing operator metrics. */
+/** Start Http service exposing operator metrics. */
 @Slf4j
 public class MetricsService {
   HttpServer server;
@@ -55,8 +56,8 @@ public class MetricsService {
   /** Starts the HTTP server and exposes the Prometheus metrics endpoint. */
   public void start() {
     log.info("Starting Metrics Service for Prometheus ...");
-    server.createContext("/prometheus", 
metricsSystem.getPrometheusPullModelHandler())
-        .getFilters().add(new HttpMethodFilter());
+    server.createContext(OPERATOR_METRICS_PATH.getValue(),
+        metricsSystem.getPrometheusPullModelHandler()).getFilters().add(new 
HttpMethodFilter());
     server.start();
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to