[BugFix] Emit valid Prometheus # TYPE lines for BE/CN JVM metrics#75240
Merged
alvin-phoenix-ai merged 1 commit intoJun 25, 2026
Merged
Conversation
JVM gauges were registered with the label baked into the metric-name
string, e.g. register_metric("jvm_heap_size_bytes{type=\"used\"}", ...).
The Prometheus exposition then printed that string verbatim after
"# TYPE ", producing illegal comment lines such as:
# TYPE starrocks_be_jvm_heap_size_bytes{type="committed"} gauge
A "# TYPE" metric name must not contain a label set, so a strict parser
rejects it. Prometheus aborts the whole scrape on the first text-format
error, so enabling enable_jvm_metrics took the node's entire metric set
offline (up=0), not just the JVM series.
Register each gauge under a bare name plus a real "type" label via
MetricLabels, mirroring stream_load_metrics. This yields one valid
"# TYPE <name>" line followed by the labelled samples. The sample lines
(name + labels) are byte-identical to before, so existing dashboards and
alerts are unaffected.
Update jvm_metrics_test to look metrics up by name + label, and add a
regression guard asserting the braced names no longer resolve.
Fixes StarRocks#75159
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Srihith Garlapati <srihith.garlapati@gmail.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Contributor
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
Contributor
[FE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
Contributor
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
kevincai
approved these changes
Jun 24, 2026
alvin-phoenix-ai
approved these changes
Jun 25, 2026
Contributor
|
@Mergifyio backport branch-4.0 |
Contributor
|
@Mergifyio backport branch-4.1 |
Contributor
✅ Backports have been createdDetails
|
Contributor
✅ Backports have been createdDetails
|
This was referenced Jun 25, 2026
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: