Skip to content

feat(cpu): add clamp_percentages option#18220

Open
tsaridas wants to merge 1 commit intoinfluxdata:masterfrom
tsaridas:clamp_percentages
Open

feat(cpu): add clamp_percentages option#18220
tsaridas wants to merge 1 commit intoinfluxdata:masterfrom
tsaridas:clamp_percentages

Conversation

@tsaridas
Copy link

@tsaridas tsaridas commented Jan 14, 2026

  • add clamp_percentages configuration option
  • implement usagePercent helper function with clamping logic
  • clamp CPU usage percentages to [0,100] range when enabled

Summary

cpu in windows can show non 0-100 values
check issue

Checklist

Related issues

resolves issue

- Add clamp_percentages configuration option
- Implement usagePercent helper function with clamping logic
- Clamp CPU usage percentages to [0,100] range when enabled
- Handle edge cases where deltas can be negative or exceed totalDelta
- Refactor to use usagePercent for both clamped and unclamped cases
- Remove duplicate code by unifying calculation path
@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger
Copy link
Contributor

@tsaridas
Copy link
Author

!signed-cla

@tsaridas tsaridas changed the title Add clamp_percentages option to CPU plugin feat(cpu): add clamp_percentages option Jan 15, 2026
@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegraf reports more than 100% cpu usage and negative values on a 40 logical cores system

1 participant