How do you calculate node CPU utilization from node_exporter?
BeginnerConceptPromQL & Recording Rules
Answer
node_cpu_seconds_total is a counter per CPU per mode. Utilization is 1 minus idle:
1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))
Memory used ratio:
1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes
Use MemAvailable, not MemFree, because Linux uses free memory for page cache.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate