hwmon: disambiguate colliding chip labels#3646
Open
mwimpelberg28 wants to merge 1 commit intoprometheus:masterfrom
Open
hwmon: disambiguate colliding chip labels#3646mwimpelberg28 wants to merge 1 commit intoprometheus:masterfrom
mwimpelberg28 wants to merge 1 commit intoprometheus:masterfrom
Conversation
Multiple hwmon nodes can be registered under a single parent device (for example asus-nb-wmi exposes one hwmon for fan control and another for WMI sensors). Both currently resolve to the same chip label (`platform_asus_nb_wmi`) and trigger "metric collected before with the same name and label values" errors at scrape time. Detect this collision in a first pass and append the chip's `name` file content (or the hwmonX basename if names also collide) to the chip label in a second pass. The include/exclude filter is moved into the same pass so user regexes match the label that is actually emitted. Fixes: prometheus#3637 Signed-off-by: Matthew Wimpelberg <matt.wimpelberg@grafana.com>
Author
|
@SuperQ would you have a moment to take a look? Happy to address any feedback. |
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.
Summary
Fixes #3637.
Multiple hwmon nodes can be registered under a single parent device — for example,
asus-nb-wmion recent ASUS laptops registers one hwmon for fan control and another for WMI sensors. Bothdevicesymlinks resolve to the same/sys/devices/platform/asus-nb-wmi, sohwmonNameproduces the sameplatform_asus_nb_wmichip label for both, and any sensor file that exists in both nodes (e.g.pwm1_enable) trips:Approach
Updatenow does two passes:/sys/class/hwmon/*, compute the device-derived base chip name for each, and count collisions.namefile content if it disambiguates, otherwise with the hwmonX basename (always unique within a boot). The include/exclude filter is also moved here so user regexes match the label that is actually emitted in the metric.Entries that already produce a unique chip label are unaffected — no surprise suffixes for users not hitting the collision.
This is closer in spirit to the discussion in #333 (the same class of bug for dual-socket
coretempboxes), but contained: the fix only kicks in when an actual collision is detected.Test plan
New
collector/hwmon_linux_test.go:TestHwmonDuplicateChipNamesAreDisambiguated— reproduces the Metric node_hwmon_pwm_enable was collected before with the same name and label values #3637 ASUS WMI scenario (two hwmon dirs sharing one platform device, both exposingpwm1_enable) and asserts bothGathersucceeds and the chip labels are distinct.TestHwmonUniqueChipNamesAreUnchanged— guards against unintended label drift for users not hitting the collision.TestHwmonDuplicateChipNamesWithSameNameFile— exercises the hwmonX-basename fallback when thenamefile content also collides.go test ./collector/), including the existing fixture-driven e2e checks.go vet ./...clean.