Skip to content

Commit

Permalink
DBZ-7913 Added Prometheus JMX exporter to server distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
jcechace committed Jun 3, 2024
1 parent deda87c commit 296a800
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
7 changes: 7 additions & 0 deletions debezium-server-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
<version.nats>2.16.3</version.nats>
<version.stan>2.2.3</version.stan>
<version.commons.logging>1.2</version.commons.logging>
<version.jmx.exporter>1.0.1</version.jmx.exporter>

<!-- Testing -->
<version.junit.pioneer>2.0.1</version.junit.pioneer>
</properties>

<dependencyManagement>
<dependencies>
<!-- Prometheus JMX exporter -->
<dependency>
<groupId>io.prometheus.jmx</groupId>
<artifactId>jmx_prometheus_javaagent</artifactId>
<version>${version.jmx.exporter}</version>
</dependency>
<!-- Aligning versions/fixing scopes -->
<dependency>
<groupId>commons-logging</groupId>
Expand Down
4 changes: 4 additions & 0 deletions debezium-server-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.prometheus.jmx</groupId>
<artifactId>jmx_prometheus_javaagent</artifactId>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-connector-mysql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<exclude>io.debezium:debezium-connector-cassandra-3</exclude>
<exclude>io.debezium:debezium-connector-cassandra-4</exclude>
<exclude>io.debezium:debezium-connector-dse</exclude>
<exclude>io.prometheus.jmx:jmx_prometheus_javaagent:*</exclude>
</excludes>
</dependencySet>
<dependencySet>
Expand All @@ -44,6 +45,16 @@
<include>jakarta.validation:*:*</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>${project.parent.artifactId}/lib_metrics</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveFiltering>true</useTransitiveFiltering>
<includes>
<include>io.prometheus.jmx:jmx_prometheus_javaagent:*</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>${project.parent.artifactId}/lib_opt</outputDirectory>
<unpack>false</unpack>
Expand Down
39 changes: 39 additions & 0 deletions debezium-server-dist/src/main/resources/distro/conf/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
startDelaySeconds: 0
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false
rules:
- pattern : "kafka.connect<type=connect-worker-metrics>([^:]+):"
name: "kafka_connect_worker_metrics_$1"
- pattern : "kafka.connect<type=connect-metrics, client-id=([^:]+)><>([^:]+)"
name: "kafka_connect_metrics_$2"
labels:
client: "$1"
- pattern: "debezium.([^:]+)<type=connector-metrics, context=([^,]+), server=([^,]+), key=([^>]+)><>RowsScanned"
name: "debezium_metrics_RowsScanned"
labels:
plugin: "$1"
name: "$3"
context: "$2"
table: "$4"
- pattern: "debezium.([^:]+)<type=connector-metrics, server=([^,]+), task=([^,]+), context=([^,]+), database=([^>]+)>([^:]+)"
name: "debezium_metrics_$6"
labels:
plugin: "$1"
name: "$2"
task: "$3"
context: "$4"
database: "$5"
- pattern: "debezium.([^:]+)<type=connector-metrics, server=([^,]+), task=([^,]+), context=([^>]+)>([^:]+)"
name: "debezium_metrics_$5"
labels:
plugin: "$1"
name: "$2"
task: "$3"
context: "$4"
- pattern: "debezium.([^:]+)<type=connector-metrics, context=([^,]+), server=([^>]+)>([^:]+)"
name: "debezium_metrics_$4"
labels:
plugin: "$1"
name: "$3"
context: "$2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# To enable Prometheus JMX exporter, set JMX_EXPORTER_PORT environment variable

if [ -n "${JMX_EXPORTER_PORT}" ]; then
JMX_EXPORTER_CONFIG=${JMX_EXPORTER_CONFIG:-"conf/metrics.yml"}
JMX_EXPORTER_AGENT_JAR=$(find lib_metrics -name "jmx_prometheus_javaagent-*.jar")
export JAVA_OPTS="-javaagent:${JMX_EXPORTER_AGENT_JAR}=0.0.0.0:${JMX_EXPORTER_PORT}:${JMX_EXPORTER_CONFIG} ${JAVA_OPTS}"
fi
1 change: 1 addition & 0 deletions debezium-server-dist/src/main/resources/distro/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ if [[ "${ENABLE_DEBEZIUM_SCRIPTING}" == "true" ]]; then
fi

source ./jmx/enable_jmx.sh
source ./lib_metrics/enable_exporter.sh

exec "$JAVA_BINARY" $DEBEZIUM_OPTS $JAVA_OPTS -cp \
$RUNNER$PATH_SEP"conf"$PATH_SEP$LIB_PATH io.debezium.server.Main

0 comments on commit 296a800

Please sign in to comment.