diff --git a/Dockerfile b/Dockerfile index 78dd2f5ca..b9c912956 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,24 @@ FROM adoptopenjdk:8-jdk-openj9 AS GRADLE_BUILD RUN mkdir -p ./build/libs/ RUN curl -L http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.6.2/jolokia-jvm-1.6.2-agent.jar -o ./jolokia-jvm-agent.jar +RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/1.0.1/jmx_prometheus_javaagent-1.0.1.jar -o ./jmx_prometheus_javaagent.jar COPY ./ ./ RUN ./gradlew build FROM openjdk:8-jre COPY --from=GRADLE_BUILD ./build/libs/ /opt/firehose/bin COPY --from=GRADLE_BUILD ./jolokia-jvm-agent.jar /opt/firehose +COPY --from=GRADLE_BUILD ./jmx_prometheus_javaagent.jar /opt/firehose COPY --from=GRADLE_BUILD ./src/main/resources/log4j.xml /opt/firehose/etc/log4j.xml COPY --from=GRADLE_BUILD ./src/main/resources/logback.xml /opt/firehose/etc/logback.xml +COPY ./jmx_exporter_config.yml /opt/firehose/etc/jmx_exporter_config.yml WORKDIR /opt/firehose -CMD ["java", "-cp", "bin/*:/work-dir/*", "org.raystack.firehose.launch.Main", "-server", "-Dlogback.configurationFile=etc/firehose/logback.xml", "-Xloggc:/var/log/firehose"] +EXPOSE 8778/tcp +EXPOSE 9404/tcp +CMD ["java", \ + "-javaagent:/opt/firehose/jmx_prometheus_javaagent.jar=9404:/opt/firehose/etc/jmx_exporter_config.yml", \ + "-cp", "bin/*:/work-dir/*", \ + "org.raystack.firehose.launch.Main", \ + "-server", \ + "-Dlogback.configurationFile=etc/firehose/logback.xml", \ + "-Xloggc:/var/log/firehose"] \ No newline at end of file diff --git a/build.gradle b/build.gradle index ff49b9fff..e8181d437 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17' - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.7" + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.5" classpath "org.ajoberstar:gradle-git:1.6.0" } } @@ -33,7 +33,7 @@ lombok { } group 'org.raystack' -version '0.8.0' +version '0.8.1' def projName = "firehose" @@ -101,7 +101,7 @@ dependencies { implementation platform('com.google.cloud:libraries-bom:20.5.0') implementation 'com.google.cloud:google-cloud-storage:2.20.1' implementation 'org.apache.logging.log4j:log4j-core:2.20.0' - implementation group: 'org.raystack', name: 'depot', version: '0.4.0' + implementation group: 'org.raystack', name: 'depot', version: '0.4.1' implementation group: 'com.networknt', name: 'json-schema-validator', version: '1.0.59' exclude group: 'org.slf4j' testImplementation group: 'junit', name: 'junit', version: '4.11' diff --git a/jmx_exporter_config.yml b/jmx_exporter_config.yml new file mode 100644 index 000000000..3ff6ba236 --- /dev/null +++ b/jmx_exporter_config.yml @@ -0,0 +1,28 @@ +rules: + - pattern: "java.lang.*" + - pattern: "java.lang" + - pattern: "java.lang" + - pattern: "java.lang" + + - pattern: 'kafka.consumer<>([a-zA-Z0-9-_]+)' + name: kafka_consumer_fetch_manager_metrics_$4 + type: GAUGE + labels: + client_id: "$1" + topic: "$2" + partition: "$3" + help: "Kafka consumer fetch manager metrics $4 for client_id $1 topic $2 and partition $3" + + - pattern: 'kafka.consumer<>([a-zA-Z0-9-_]+)' + name: kafka_consumer_coordinator_metrics_$2 + type: GAUGE + labels: + client_id: "$1" + help: "Kafka consumer coordinator metrics $2 for client_id $1" + + - pattern: 'kafka.consumer<>([a-zA-Z0-9-_]+)' + name: kafka_consumer_consumer_metrics_$2 + type: GAUGE + labels: + client_id: "$1" + help: "Kafka consumer consumer metrics $2 for client_id $1"