Skip to content

collector/cpu: avoid frequency_hertz clash with cpufreq#3749

Open
locker95 wants to merge 1 commit into
prometheus:masterfrom
locker95:fix/cpu-frequency-help-conflict
Open

collector/cpu: avoid frequency_hertz clash with cpufreq#3749
locker95 wants to merge 1 commit into
prometheus:masterfrom
locker95:fix/cpu-frequency-help-conflict

Conversation

@locker95

Copy link
Copy Markdown

What

node_cpu_frequency_hertz was being emitted from both the cpu.info path (/proc/cpuinfo) and the cpufreq collector, with different help strings and label sets. On hosts where both sources actually produce samples (often large-core machines), Prometheus gather fails:

collected metric node_cpu_frequency_hertz ... has help "Current CPU thread frequency in hertz." but should have "CPU frequency in hertz from /proc/cpuinfo."

Why

#3318 flipped the guard so cpu.info always emitted frequency while cpufreq was enabled. That restored the metric in some setups, but made the two collectors share a metric name they cannot share.

Fix

Only export /proc/cpuinfo frequency when the cpufreq collector is disabled. When cpufreq is on, it owns node_cpu_frequency_hertz.

Updated the e2e fixture accordingly (those samples only appeared because of the broken dual export; the fixture has no cpuinfo_cur_freq for the cpufreq path).

Test

go test ./collector/ -count=1 -short
go build .

Fixes #3689

Both collectors export node_cpu_frequency_hertz, but with different
help text and labels. When cpu.info and cpufreq run together (the
common case), Prometheus gather fails with inconsistent help strings.

Only fall back to /proc/cpuinfo when the cpufreq collector is disabled.
Drop the overlapping samples from the e2e fixture.

Fixes prometheus#3689

Signed-off-by: Dean Chen <862469039@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conflicting help texts for node_cpu_frequency_hertz

1 participant