Repository navigation
textfile: use the explicit help text for families without one - #3882
Closed
shivanshdevops wants to merge 1 commit into
Closed
shivanshdevops wants to merge 1 commit into
shivanshdevops wants to merge 1 commit into
Conversation
When the same metric is read from several .prom files and only some of them carry a `# HELP` line, the families without one were given a generated "Metric read from ..." help text. That differs from the explicit help text, so the registry rejected the inconsistent families and the series from the files with `# HELP` were silently dropped, without setting node_textfile_scrape_error. Families without a help text now inherit the explicit help text that another file gave for the same metric. The generated text is still used when no file provides one. This also fixes a nil pointer dereference in the inconsistency check: once two files had given conflicting help texts, a third file without a help text for that metric made the collector panic. Fixes prometheus#3052 Signed-off-by: shivanshdevops <shivanshdevops@gmail.com>
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.
@SuperQ @discordianfish
Fixes #3052
Problem
The textfile collector merges metric families with the same name across
.promfiles.When only some of those files carry a
# HELPline, the families without one were given the generatedMetric read from <files>help text.That text differs from the explicit one, so the registry treats the families as inconsistent and drops part of the metric:
With
a.prom(no HELP),b.prom(HELP) andc.prom(no HELP), the series fromb.prom, the only file that documents the metric, disappear from the output, andnode_textfile_scrape_errorstays0, so nothing signals the loss.While reproducing this I also hit a nil pointer dereference in the same check.
Once two files had given conflicting help texts for a metric, the condition
mf.Help != nil && helpTexts[0] != *mf.Help || helpTexts[1] != ""evaluates to true for a third file without a help text, and the branch then dereferencesmf.Help:client_golang recovers the panic, but every metric from the textfile collector is lost for that scrape.
Changes
This removes the nil dereference; the existing behaviour for conflicting explicit help texts (keep the first, drop the others, set
node_textfile_scrape_errorto1) is unchanged.Metric read from ...text, families without a help text now take the explicit help text recorded for the same metric.The generated text is still used when no file provides one.
Tests
Two fixture-driven cases are added to the existing
TestTextfileCollectortable:metrics_merge_partial_help: HELP only in the middle file; all six series are exported under the explicit help text andnode_textfile_scrape_erroris0.On
mastertheb.promseries are missing.metrics_merge_different_and_no_help: two conflicting help texts plus a file without one; the first help text wins, the conflicting file is dropped, the file without help is merged, andnode_textfile_scrape_erroris1.On
masterthis panics.Verified with:
make testGOOS=linux golangci-lint run ./...(v2.14.0, frommake print-golangci-lint-version): 0 issuesGOOS=linux go vet ./...