Repository navigation
Conversation
Registers a constant Micrometer gauge keycloak.build.info with a
version tag via a MeterBinder bean in the Quarkus runtime, rendered
as keycloak_build_info{version="..."} 1 on the metrics endpoint
whenever metrics are enabled. This follows the Prometheus *_info
convention of jvm_info and gives inventory and monitoring tools a
least-privilege way to read the Keycloak version without an admin
token for /admin/serverinfo.
Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change exposing Keycloak version information through metrics.
No open issues 🎉
What changed in this PR
Exposes the Keycloak version through the existing metrics endpoint, enabling fleet inventory and upgrade tracking without access to the admin API.
Changes:
- Adds a constant
keycloak_build_infogauge with aversiontag, registered when metrics are enabled. - Extends the metrics integration test to check the gauge type and version label.
- Documents the metric, its tag, and an example scrape response.
| File | Description |
|---|---|
quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/MetricsDistTest.java |
Adds assertions for the build-info metric. |
quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/services/metrics/KeycloakBuildInfoMeter.java |
Registers the constant version gauge through a Micrometer binder. |
docs/guides/observability/metrics-for-troubleshooting-keycloak.adoc |
Documents build-info metrics for inventory and monitoring. |
Review effort: Balanced
The CI Build job failed on spotless:check because jakarta.inject.Singleton was grouped after the io.micrometer imports instead of before the org.keycloak import, as required by the project import-order rules. Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
Contributor
Author
|
The red Build job was a Spotless import-order violation in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #55259
What
Registers a constant gauge
keycloak.build.infowith aversiontag whenever metrics are enabled. The Prometheus registry renders it askeycloak_build_info, so scraping the management interface's/metricsendpoint yields:This follows the Prometheus
*_infoconvention already used byjvm_info, and gives inventory and monitoring tools that already scrape/metricsa least-privilege way to read the Keycloak version — today it is only available from/admin/serverinfo, which requires a token withmanage-realm(the permission split is tracked in #48961), or from the startup log.How
A new Micrometer
MeterBinderbean (KeycloakBuildInfoMeter) in the Quarkus runtime registers the gauge on theVersionconstant. Quarkus appliesMeterBinderbeans to the global registry on startup (the same mechanismHistogramMeterFilterrelies on forMeterFilterbeans), so the metric appears whenever metrics are enabled and needs no additional configuration.Docs
The "Self-provided metrics" observability guide gains a Build info section (metric table, tags, example scrape).
Testing
quarkus/tests/integrationMetricsDistTest#testMetricsEndpointnow assertsTYPE keycloak_build_info gaugeand thekeycloak_build_info{version="..."}sample (runs in the Quarkus IT CI job).keycloak.build.infowith aversiontag scrapes exactly as shown above.mvn -pl quarkus/runtime compileandmvn -pl quarkus/runtime installpass.