diff --git a/.gitignore b/.gitignore index cf35b2d..dc6af10 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,8 @@ # Ignore Gradle build output directory build +bin .DS_Store .idea + +settings-gradle.lockfile \ No newline at end of file diff --git a/docstore-metrics/gradle.lockfile b/docstore-metrics/gradle.lockfile index 1ff5398..cfe2146 100644 --- a/docstore-metrics/gradle.lockfile +++ b/docstore-metrics/gradle.lockfile @@ -23,13 +23,26 @@ io.micrometer:micrometer-commons:1.14.4=compileClasspath,runtimeClasspath,testCo io.micrometer:micrometer-core:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=runtimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=runtimeClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_pushgateway:0.16.0=runtimeClasspath,testRuntimeClasspath -io.prometheus:simpleclient_servlet_common:0.16.0=runtimeClasspath,testRuntimeClasspath -io.prometheus:simpleclient_servlet_jakarta:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_tracer_common:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_tracer_otel:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_tracer_otel_agent:0.16.0=runtimeClasspath,testRuntimeClasspath diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 422f540..02ff56d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,6 +2,8 @@ dropwizard-metrics = "4.2.25" micrometer = "1.14.4" prometheus-simpleclient = "0.16.0" +# Aligns with the io.prometheus:* transitives pulled in by micrometer-registry-prometheus. +prometheus = "1.3.5" caffeine = "3.1.8" [libraries] @@ -12,10 +14,15 @@ dropwizard-metrics-jakarta-servlets = { module = "io.dropwizard.metrics:metrics- dropwizard-metrics-jvm = { module = "io.dropwizard.metrics:metrics-jvm", version.ref = "dropwizard-metrics" } micrometer-core = { module = "io.micrometer:micrometer-core", version.ref = "micrometer" } micrometer-registry-prometheus-simpleclient = { module = "io.micrometer:micrometer-registry-prometheus-simpleclient", version.ref = "micrometer" } +micrometer-registry-prometheus = { module = "io.micrometer:micrometer-registry-prometheus", version.ref = "micrometer" } +prometheus-exporter-httpserver = { module = "io.prometheus:prometheus-metrics-exporter-httpserver", version.ref = "prometheus" } +prometheus-exporter-servlet-jakarta = { module = "io.prometheus:prometheus-metrics-exporter-servlet-jakarta", version.ref = "prometheus" } +prometheus-instrumentation-dropwizard = { module = "io.prometheus:prometheus-metrics-instrumentation-dropwizard", version.ref = "prometheus" } +prometheus-simpleclient-bridge = { module = "io.prometheus:prometheus-metrics-simpleclient-bridge", version.ref = "prometheus" } micrometer-jvm-extras = { module = "io.github.mweirauch:micrometer-jvm-extras", version = "0.2.2" } -prometheus-simpleclient-dropwizard = { module = "io.prometheus:simpleclient_dropwizard", version.ref = "prometheus-simpleclient" } prometheus-simpleclient-servlet-jakarta = { module = "io.prometheus:simpleclient_servlet_jakarta", version.ref = "prometheus-simpleclient" } prometheus-simpleclient-pushgateway = { module = "io.prometheus:simpleclient_pushgateway", version.ref = "prometheus-simpleclient" } +prometheus-simpleclient-dropwizard = { module = "io.prometheus:simpleclient_dropwizard", version.ref = "prometheus-simpleclient" } caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" } apache-httpcomponents-httpclient = { module = "org.apache.httpcomponents:httpclient", version = "4.5.13" } diff --git a/integrationtest-service-framework/gradle.lockfile b/integrationtest-service-framework/gradle.lockfile index 2d7c9c4..45ef709 100644 --- a/integrationtest-service-framework/gradle.lockfile +++ b/integrationtest-service-framework/gradle.lockfile @@ -27,7 +27,23 @@ io.micrometer:micrometer-commons:1.14.4=runtimeClasspath,testRuntimeClasspath io.micrometer:micrometer-core:1.14.4=runtimeClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=runtimeClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=runtimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=runtimeClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-servlet-jakarta:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=runtimeClasspath,testRuntimeClasspath diff --git a/platform-grpc-service-framework/gradle.lockfile b/platform-grpc-service-framework/gradle.lockfile index 4d87019..36ccc85 100644 --- a/platform-grpc-service-framework/gradle.lockfile +++ b/platform-grpc-service-framework/gradle.lockfile @@ -46,6 +46,7 @@ io.micrometer:micrometer-commons:1.14.4=compileClasspath,runtimeClasspath,testCo io.micrometer:micrometer-core:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=runtimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=runtimeClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.netty:netty-buffer:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.netty:netty-codec-http2:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -59,6 +60,21 @@ io.netty:netty-resolver:4.1.136.Final=compileClasspath,runtimeClasspath,testComp io.netty:netty-transport-native-unix-common:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.netty:netty-transport:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.perfmark:perfmark-api:0.27.0=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-servlet-jakarta:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=runtimeClasspath,testRuntimeClasspath diff --git a/platform-http-service-framework/gradle.lockfile b/platform-http-service-framework/gradle.lockfile index b77e440..950b513 100644 --- a/platform-http-service-framework/gradle.lockfile +++ b/platform-http-service-framework/gradle.lockfile @@ -45,8 +45,24 @@ io.micrometer:micrometer-commons:1.14.4=compileClasspath,runtimeClasspath,testCo io.micrometer:micrometer-core:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=runtimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=runtimeClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.perfmark:perfmark-api:0.27.0=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-servlet-jakarta:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=runtimeClasspath,testRuntimeClasspath diff --git a/platform-hybrid-service-framework/gradle.lockfile b/platform-hybrid-service-framework/gradle.lockfile index eccdd83..14f126f 100644 --- a/platform-hybrid-service-framework/gradle.lockfile +++ b/platform-hybrid-service-framework/gradle.lockfile @@ -50,6 +50,7 @@ io.micrometer:micrometer-commons:1.14.4=runtimeClasspath,testRuntimeClasspath io.micrometer:micrometer-core:1.14.4=runtimeClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=runtimeClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=runtimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=runtimeClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.netty:netty-buffer:4.1.136.Final=runtimeClasspath,testRuntimeClasspath io.netty:netty-codec-http2:4.1.136.Final=runtimeClasspath,testRuntimeClasspath @@ -63,6 +64,21 @@ io.netty:netty-resolver:4.1.136.Final=runtimeClasspath,testRuntimeClasspath io.netty:netty-transport-native-unix-common:4.1.136.Final=runtimeClasspath,testRuntimeClasspath io.netty:netty-transport:4.1.136.Final=runtimeClasspath,testRuntimeClasspath io.perfmark:perfmark-api:0.27.0=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-servlet-jakarta:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=runtimeClasspath,testRuntimeClasspath diff --git a/platform-metrics/README.md b/platform-metrics/README.md index b193b97..3242491 100644 --- a/platform-metrics/README.md +++ b/platform-metrics/README.md @@ -42,3 +42,8 @@ counter.increment(); ## References This library uses MicroMeter for metrics, and the API of MicroMeter is exposed directly to leverage the power of it. See https://micrometer.io/docs for more details. + +For Flink TaskManagers, `SharedMeterRegistry.getPrometheusRegistry(serviceName, port)` +binds the process scrape endpoint and returns the Prometheus registry so a Flink metric +reporter can bridge Flink-native metrics onto the same endpoint. Application meters still +go through `PlatformMetricsRegistry.getMeterRegistry()`. diff --git a/platform-metrics/build.gradle.kts b/platform-metrics/build.gradle.kts index 1c61f2b..62884aa 100644 --- a/platform-metrics/build.gradle.kts +++ b/platform-metrics/build.gradle.kts @@ -15,18 +15,33 @@ dependencies { api(localLibs.micrometer.core) api(localLibs.jakarta.servlet.api) + // New Prometheus client stack (io.micrometer.prometheusmetrics / io.prometheus.metrics). + implementation(localLibs.micrometer.registry.prometheus) + // Standalone HTTP server that exposes the Prometheus scrape endpoint (SharedMeterRegistry). + implementation(localLibs.prometheus.exporter.httpserver) + // Bridges Dropwizard MetricRegistry into the new PrometheusRegistry. + implementation(localLibs.prometheus.instrumentation.dropwizard) + // Bridges the legacy simpleclient CollectorRegistry onto the new PrometheusRegistry. + implementation(localLibs.prometheus.simpleclient.bridge) + + // Legacy simpleclient stack — still required by PrometheusPushMeterRegistry + // (io.micrometer.prometheus.PrometheusMeterRegistry + PushGateway). implementation(localLibs.micrometer.registry.prometheus.simpleclient) + implementation(localLibs.prometheus.simpleclient.pushgateway) + // Bridges Dropwizard MetricRegistry into the legacy simpleclient CollectorRegistry. + implementation(localLibs.prometheus.simpleclient.dropwizard) + implementation(localLibs.micrometer.jvm.extras) implementation(commonLibs.slf4j2.api) implementation(localLibs.dropwizard.metrics.jvm) - implementation(localLibs.prometheus.simpleclient.dropwizard) - implementation(localLibs.prometheus.simpleclient.servlet.jakarta) - implementation(localLibs.prometheus.simpleclient.pushgateway) implementation(commonLibs.jetty.servlet) implementation(commonLibs.guava) compileOnly(localLibs.caffeine) + annotationProcessor(commonLibs.lombok) + compileOnly(commonLibs.lombok) + testImplementation(commonLibs.junit.jupiter) testImplementation(commonLibs.mockito.core) testImplementation(localLibs.caffeine) diff --git a/platform-metrics/gradle.lockfile b/platform-metrics/gradle.lockfile index d720b90..dd08fca 100644 --- a/platform-metrics/gradle.lockfile +++ b/platform-metrics/gradle.lockfile @@ -21,13 +21,26 @@ io.micrometer:micrometer-commons:1.14.4=compileClasspath,runtimeClasspath,testCo io.micrometer:micrometer-core:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_pushgateway:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.prometheus:simpleclient_servlet_common:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.prometheus:simpleclient_servlet_jakarta:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_tracer_common:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_tracer_otel:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_tracer_otel_agent:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -63,5 +76,6 @@ org.latencyutils:LatencyUtils:2.0.3=runtimeClasspath,testRuntimeClasspath org.mockito:mockito-core:5.8.0=testCompileClasspath,testRuntimeClasspath org.objenesis:objenesis:3.3=testRuntimeClasspath org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.projectlombok:lombok:1.18.30=annotationProcessor,compileClasspath org.slf4j:slf4j-api:2.0.17=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -empty=annotationProcessor +empty= diff --git a/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/PlatformMetricsRegistry.java b/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/PlatformMetricsRegistry.java index 2930878..c67e115 100644 --- a/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/PlatformMetricsRegistry.java +++ b/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/PlatformMetricsRegistry.java @@ -5,6 +5,7 @@ import com.codahale.metrics.MetricRegistry; import com.google.common.cache.Cache; import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; import io.github.mweirauch.micrometer.jvm.extras.ProcessMemoryMetrics; import io.github.mweirauch.micrometer.jvm.extras.ProcessThreadMetrics; import io.micrometer.common.util.StringUtils; @@ -41,6 +42,8 @@ import io.prometheus.client.CollectorRegistry; import io.prometheus.client.dropwizard.DropwizardExports; import io.prometheus.client.exporter.PushGateway; +import io.prometheus.metrics.model.registry.PrometheusRegistry; +import io.prometheus.metrics.simpleclient.bridge.SimpleclientCollector; import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; @@ -88,6 +91,7 @@ public class PlatformMetricsRegistry { private static final String METRICS_DEFAULT_TAGS_CONFIG_KEY = "defaultTags"; private static final MetricRegistry METRIC_REGISTRY = new MetricRegistry(); + private static final PrometheusRegistry PROMETHEUS_REGISTRY = new PrometheusRegistry(); public static final List DEFAULT_METRICS_REPORTERS = List.of("prometheus"); private static ConsoleReporter consoleReporter; @@ -105,6 +109,7 @@ private static void initPrometheusReporter(int reportInterval) { LOGGER.info("Trying to init PrometheusReporter"); // Add Prometheus registry to the composite registry. + // fixme: this uses deprecated prometheus client and needs to be migrated to the newer API meterRegistry.add( new PrometheusMeterRegistry( new PrometheusConfig() { @@ -124,6 +129,11 @@ public String get(String k) { Clock.SYSTEM)); CollectorRegistry.defaultRegistry.register(new DropwizardExports(METRIC_REGISTRY)); + // exposing the metrics registered via the Collector Registry to a Prometheus instance which + // will be served via a separate prometheus server. + SimpleclientCollector.builder() + .collectorRegistry(CollectorRegistry.defaultRegistry) + .register(PROMETHEUS_REGISTRY); } private static void initConsoleMetricsReporter(final int reportIntervalSec) { @@ -208,6 +218,19 @@ private static List getStringList(Config config, String path, ListApplication meters still report through {@link PlatformMetricsRegistry#getMeterRegistry()}; + * this class only binds the HTTP scrape server and exposes the underlying {@link + * PrometheusRegistry} so Flink's metric reporter can bridge Flink-native metrics onto the same + * endpoint. The exporter is started exactly once per JVM: the port from the first caller wins, and + * later callers reuse that instance. + * + *

Parameters are primitives / {@link String} on purpose so this class can sit on Flink's + * parent-first shared classpath without coupling that surface to typesafe-config. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class SharedMeterRegistry { + + private static boolean initialized = false; + + /** + * Returns the process-wide Prometheus registry, starting {@link PlatformMetricsRegistry} and the + * scrape-endpoint HTTP server on first use. + * + * @param serviceName service name added to the common metric tags + * @param exporterPort the port on which to publish the Prometheus scrape endpoint + * @return the shared Prometheus registry + */ + public static synchronized PrometheusRegistry getOrCreatePrometheusRegistry( + String serviceName, int exporterPort) { + if (!initialized) { + PlatformMetricsRegistry.initMetricsRegistryForFlink(serviceName); + try { + HTTPServer.builder() + .port(exporterPort) + .registry(PlatformMetricsRegistry.getPrometheusRegistry()) + .buildAndStart(); + } catch (IOException e) { + throw new UncheckedIOException("Failed to start Prometheus exporter HTTP server", e); + } + initialized = true; + } + return PlatformMetricsRegistry.getPrometheusRegistry(); + } +} diff --git a/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/registry/PrometheusPushMeterRegistry.java b/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/registry/PrometheusPushMeterRegistry.java index f72f129..32dfdfc 100644 --- a/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/registry/PrometheusPushMeterRegistry.java +++ b/platform-metrics/src/main/java/org/hypertrace/core/serviceframework/metrics/registry/PrometheusPushMeterRegistry.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; /** Metric Registry for Prometheus Push Gateway */ +// fixme: this also uses deprecated prometheus client and needs migration public class PrometheusPushMeterRegistry extends PrometheusMeterRegistry { private static final Logger logger = LoggerFactory.getLogger(PlatformMetricsRegistry.class); private final PrometheusPushRegistryConfig pushConfig; diff --git a/platform-service-framework/build.gradle.kts b/platform-service-framework/build.gradle.kts index 400ae11..671db2f 100644 --- a/platform-service-framework/build.gradle.kts +++ b/platform-service-framework/build.gradle.kts @@ -22,6 +22,7 @@ dependencies { // Use for metrics servlet implementation(localLibs.prometheus.simpleclient.servlet.jakarta) + implementation(localLibs.prometheus.exporter.servlet.jakarta) testImplementation(commonLibs.log4j.slf4j2.impl) testImplementation(commonLibs.junit.jupiter) diff --git a/platform-service-framework/gradle.lockfile b/platform-service-framework/gradle.lockfile index 1bb33ae..595e7f8 100644 --- a/platform-service-framework/gradle.lockfile +++ b/platform-service-framework/gradle.lockfile @@ -29,7 +29,23 @@ io.micrometer:micrometer-commons:1.14.4=compileClasspath,runtimeClasspath,testCo io.micrometer:micrometer-core:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.14.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-registry-prometheus-simpleclient:1.14.4=runtimeClasspath,testRuntimeClasspath +io.micrometer:micrometer-registry-prometheus:1.14.4=runtimeClasspath,testRuntimeClasspath io.netty:netty-bom:4.1.136.Final=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-config:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-core:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-common:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-httpserver:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exporter-servlet-jakarta:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-formats:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-exposition-textformats:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard5:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-instrumentation-dropwizard:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-model:1.3.5=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-simpleclient-bridge:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-common:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-initializer:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel-agent:1.3.5=runtimeClasspath,testRuntimeClasspath +io.prometheus:prometheus-metrics-tracer-otel:1.3.5=runtimeClasspath,testRuntimeClasspath io.prometheus:simpleclient:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_common:0.16.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.prometheus:simpleclient_dropwizard:0.16.0=runtimeClasspath,testRuntimeClasspath