Skip to content

Commit 76ce745

Browse files
senthhSteNicholas
authored andcommitted
[CELEBORN-2380] Support JmxSink for exposing metrics as JMX MBeans
### What changes were proposed in this pull request? This PR adds a new `JmxSink` metrics sink that exposes Celeborn metrics as JMX MBeans. - Add `JmxSink` (`common/src/main/scala/org/apache/celeborn/common/metrics/sink/JmxSink.scala`), backed by Dropwizard Metrics' `JmxReporter`. It follows the existing `Sink` contract and is loaded reflectively by `MetricsSystem` via the standard `(Properties, MetricRegistry)` constructor, so no changes to `MetricsSystem` are required. - Add the `io.dropwizard.metrics:metrics-jmx` dependency (which contains `JmxReporter` in Dropwizard Metrics 4.x) to both the Maven build (`pom.xml` dependency management + `common/pom.xml`) and the SBT build (`project/CelebornBuild.scala`), pinned to the existing `${codahale.metrics.version}` (4.2.25). - Add a commented-out example to `conf/metrics.properties.template` and `charts/celeborn/files/conf/metrics.properties` showing how to enable the sink. - Document `JmxSink` in `docs/monitoring.md`. - Register `metrics-jmx-4.2.25.jar` in all `dev/deps/dependencies-*` manifests (server + client profiles) and add `io.dropwizard.metrics:metrics-jmx` to `LICENSE-binary`, since the artifact is now bundled in the distributions. Enabling the sink is opt-in: ```properties *.sink.jmx.class=org.apache.celeborn.common.metrics.sink.JmxSink Test Output: <img width="1315" height="800" alt="Celeborn_jmx" src="https://github.com/user-attachments/assets/7af729f8-7eb9-4749-af9c-e2af64d48fb8" /> Closes #3758 from senthh/CELEBORN-2380. Lead-authored-by: senthh <senthil.kumar@acceldata.io> Co-authored-by: senthh <senthh@gmail.com> Signed-off-by: Nicholas Jiang <programgeek@163.com>
1 parent 59413d0 commit 76ce745

31 files changed

Lines changed: 250 additions & 6 deletions

LICENSE-binary

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ com.zaxxer:HikariCP
226226
info.picocli:picocli
227227
io.dropwizard.metrics:metrics-core
228228
io.dropwizard.metrics:metrics-graphite
229+
io.dropwizard.metrics:metrics-jmx
229230
io.dropwizard.metrics:metrics-jvm
230231
io.netty:netty-all
231232
io.netty:netty-buffer

charts/celeborn/files/conf/metrics.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
*.sink.prometheusServlet.class=org.apache.celeborn.common.metrics.sink.PrometheusServlet
1919
*.sink.jsonServlet.class=org.apache.celeborn.common.metrics.sink.JsonServlet
2020
*.sink.loggerSink.class=org.apache.celeborn.common.metrics.sink.LoggerSink
21+
22+
# Expose metrics as JMX MBeans.
23+
*.sink.jmx.class=org.apache.celeborn.common.metrics.sink.JmxSink

charts/celeborn/tests/master/statefulset_test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tests:
4040
asserts:
4141
- equal:
4242
path: spec.template.metadata.annotations["celeborn.apache.org/conf-hash"]
43-
value: 7e9a27719ab1f2c1cea53e4879a807782abd48d87ec2a45774084990af6125b3
43+
value: 035c23a53d85eb407eecf3fe864be5e623afae38e8ecdd4c10579e76d85f5c6b
4444

4545
- it: Should change checksum annotation when celeborn config changes
4646
template: master/statefulset.yaml
@@ -50,10 +50,10 @@ tests:
5050
asserts:
5151
- notEqual:
5252
path: spec.template.metadata.annotations["celeborn.apache.org/conf-hash"]
53-
value: 7e9a27719ab1f2c1cea53e4879a807782abd48d87ec2a45774084990af6125b3
53+
value: 035c23a53d85eb407eecf3fe864be5e623afae38e8ecdd4c10579e76d85f5c6b
5454
- equal:
5555
path: spec.template.metadata.annotations["celeborn.apache.org/conf-hash"]
56-
value: 118d5c045d52fbbd4e8f05cf0522044373165960aa57893f645a6f9e8844dd68
56+
value: d15c180987eca7e3b13dc37e3277c057a4060799ddd45cf20490ebb91da21ee1
5757

5858
- it: Should add extra pod annotations if `master.annotations` is specified
5959
template: master/statefulset.yaml

charts/celeborn/tests/worker/statefulset_test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tests:
4040
asserts:
4141
- equal:
4242
path: spec.template.metadata.annotations["celeborn.apache.org/conf-hash"]
43-
value: 7e9a27719ab1f2c1cea53e4879a807782abd48d87ec2a45774084990af6125b3
43+
value: 035c23a53d85eb407eecf3fe864be5e623afae38e8ecdd4c10579e76d85f5c6b
4444

4545
- it: Should change checksum annotation when celeborn config changes
4646
template: worker/statefulset.yaml
@@ -50,10 +50,10 @@ tests:
5050
asserts:
5151
- notEqual:
5252
path: spec.template.metadata.annotations["celeborn.apache.org/conf-hash"]
53-
value: 7e9a27719ab1f2c1cea53e4879a807782abd48d87ec2a45774084990af6125b3
53+
value: 035c23a53d85eb407eecf3fe864be5e623afae38e8ecdd4c10579e76d85f5c6b
5454
- equal:
5555
path: spec.template.metadata.annotations["celeborn.apache.org/conf-hash"]
56-
value: 118d5c045d52fbbd4e8f05cf0522044373165960aa57893f645a6f9e8844dd68
56+
value: d15c180987eca7e3b13dc37e3277c057a4060799ddd45cf20490ebb91da21ee1
5757

5858
- it: Should add extra pod annotations if `worker.annotations` is specified
5959
template: worker/statefulset.yaml

common/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<groupId>io.dropwizard.metrics</groupId>
4848
<artifactId>metrics-jvm</artifactId>
4949
</dependency>
50+
<dependency>
51+
<groupId>io.dropwizard.metrics</groupId>
52+
<artifactId>metrics-jmx</artifactId>
53+
</dependency>
5054
<dependency>
5155
<groupId>org.yaml</groupId>
5256
<artifactId>snakeyaml</artifactId>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.celeborn.common.metrics.sink
19+
20+
import java.util.Properties
21+
22+
import com.codahale.metrics.MetricRegistry
23+
import com.codahale.metrics.jmx.JmxReporter
24+
25+
class JmxSink(val property: Properties, val registry: MetricRegistry) extends Sink {
26+
27+
// Publish MBeans under a configurable, Celeborn-specific JMX domain (defaulting to
28+
// `celeborn`) rather than JmxReporter's global default domain `metrics`. This avoids
29+
// MBean name collisions when other components using Dropwizard metrics run in the
30+
// same JVM. The domain can be overridden via `*.sink.jmx.domain=<domain>`.
31+
val domain: String =
32+
Option(property.getProperty(JmxSink.JMX_DOMAIN_KEY))
33+
.map(_.trim)
34+
.filter(_.nonEmpty)
35+
.getOrElse(JmxSink.JMX_DEFAULT_DOMAIN)
36+
37+
val reporter: JmxReporter = JmxReporter.forRegistry(registry)
38+
.inDomain(domain)
39+
.build()
40+
41+
override def start(): Unit = {
42+
reporter.start()
43+
}
44+
45+
override def stop(): Unit = {
46+
reporter.stop()
47+
}
48+
49+
override def report(): Unit = {}
50+
}
51+
52+
object JmxSink {
53+
val JMX_DOMAIN_KEY = "domain"
54+
val JMX_DEFAULT_DOMAIN = "celeborn"
55+
}

conf/metrics.properties.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
*.sink.prometheusServlet.class=org.apache.celeborn.common.metrics.sink.PrometheusServlet
1919
*.sink.jsonServlet.class=org.apache.celeborn.common.metrics.sink.JsonServlet
2020
*.sink.loggerSink.class=org.apache.celeborn.common.metrics.sink.LoggerSink
21+
22+
# Expose metrics as JMX MBeans. Disabled by default; uncomment to enable.
23+
# MBeans are published under the `celeborn` JMX domain by default; override with
24+
# `*.sink.jmx.domain=<domain>` if needed.
25+
# *.sink.jmx.class=org.apache.celeborn.common.metrics.sink.JmxSink

dev/deps/dependencies-client-flink-1.18

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ lz4-java/1.10.4//lz4-java-1.10.4.jar
3636
maven-jdk-tools-wrapper/0.1//maven-jdk-tools-wrapper-0.1.jar
3737
metrics-core/4.2.25//metrics-core-4.2.25.jar
3838
metrics-graphite/4.2.25//metrics-graphite-4.2.25.jar
39+
metrics-jmx/4.2.25//metrics-jmx-4.2.25.jar
3940
metrics-jvm/4.2.25//metrics-jvm-4.2.25.jar
4041
netty-all/4.2.10.Final//netty-all-4.2.10.Final.jar
4142
netty-buffer/4.2.10.Final//netty-buffer-4.2.10.Final.jar

dev/deps/dependencies-client-flink-1.19

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ lz4-java/1.10.4//lz4-java-1.10.4.jar
3636
maven-jdk-tools-wrapper/0.1//maven-jdk-tools-wrapper-0.1.jar
3737
metrics-core/4.2.25//metrics-core-4.2.25.jar
3838
metrics-graphite/4.2.25//metrics-graphite-4.2.25.jar
39+
metrics-jmx/4.2.25//metrics-jmx-4.2.25.jar
3940
metrics-jvm/4.2.25//metrics-jvm-4.2.25.jar
4041
netty-all/4.2.10.Final//netty-all-4.2.10.Final.jar
4142
netty-buffer/4.2.10.Final//netty-buffer-4.2.10.Final.jar

dev/deps/dependencies-client-flink-1.20

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ lz4-java/1.10.4//lz4-java-1.10.4.jar
3636
maven-jdk-tools-wrapper/0.1//maven-jdk-tools-wrapper-0.1.jar
3737
metrics-core/4.2.25//metrics-core-4.2.25.jar
3838
metrics-graphite/4.2.25//metrics-graphite-4.2.25.jar
39+
metrics-jmx/4.2.25//metrics-jmx-4.2.25.jar
3940
metrics-jvm/4.2.25//metrics-jvm-4.2.25.jar
4041
netty-all/4.2.10.Final//netty-all-4.2.10.Final.jar
4142
netty-buffer/4.2.10.Final//netty-buffer-4.2.10.Final.jar

0 commit comments

Comments
 (0)