[BugFix] Emit valid Prometheus # TYPE lines for BE/CN JVM metrics (backport #75240)#75369
Merged
Merged
Conversation
23 tasks
kevincai
approved these changes
Jun 25, 2026
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Why I'm doing:
enable_jvm_metrics = truemakes the BE/CN/metricsendpoint emit invalidPrometheus text. Each JVM gauge is registered with its label baked into the
metric-name string, e.g.:
so the exposition prints that string verbatim after
# TYPE:A
# TYPEmetric name must not contain a label set. Prometheus aborts theentire scrape on the first text-format error, so flipping this flag on
takes the node's whole metric set offline (
up == 0) — not just the JVMseries.
promtool check metricsrejects it withinvalid metric name in comment. Reproduced on 4.0.10/4.0.11 andmain; the feature shipped in 4.0.0(#62210).
What I'm doing:
Register each JVM gauge under a bare metric name plus a real
typelabel viaMetricLabels, mirroring the existingstream_load_metricspattern. Themetrics framework then emits one valid
# TYPE <name>line followed by thelabelled samples:
The sample lines (name + labels) are byte-identical to before, so the
time-series identity is unchanged and existing dashboards/alerts keep working;
only the previously-malformed
# TYPEcomment is corrected. No metric isrenamed, so no docs change is required.
jvm_metrics_testis updated to look metrics up by name + label, plus aregression guard asserting the old braced names no longer resolve (which would
mean the label was still baked into the name).
Fixes #75159
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
This is an automatic backport of pull request #75240 done by [Mergify](https://mergify.com).