Repository navigation
Conversation
shk1999
force-pushed
the
develop
branch
4 times, most recently
from
October 1, 2025 06:31
c5153e3 to
abd4dc2
Compare
Signed-off-by: shk1999 <shayan000karimi@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses Prometheus “duplicate metric collected” conflicts by detecting repeated label sets during ObjectScrape collection and skipping duplicate samples so a scrape can complete successfully.
Changes:
- Adds per-metric duplicate detection for
ObjectScraperesults using aseenset keyed by extracted label values. - Skips emitting metrics whose label set has already been emitted during the same metric collection loop and logs a message when skipping.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+99
to
+101
| if _, exists := seen[labelKey]; exists { | ||
| mc.Logger.Warn("Skipping duplicate metric with identical labels", "metric", m.Desc, "labels", fmt.Sprintf("%v", labels)) | ||
| continue |
Comment on lines
+97
to
+103
| labels := extractLabels(mc.Logger, jdata, m.LabelsJSONPaths) | ||
| labelKey := strings.Join(labels, "\x00") | ||
| if _, exists := seen[labelKey]; exists { | ||
| mc.Logger.Warn("Skipping duplicate metric with identical labels", "metric", m.Desc, "labels", fmt.Sprintf("%v", labels)) | ||
| continue | ||
| } | ||
| seen[labelKey] = struct{}{} |
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.
This commit fixes the metric conflicts
#394
in my case, the json_exporter could not resolve the /api/v1/alerts of prometheus instances due to a lot of duplicated labels (e.g. value, annotations, alertname, etc)