I want to generate graphs that approximately mirror what Windows task-manager shows for CPU/memory %.
For CPU, I thought windows_cpu_processor_performance should do this, labeled by core. But it always returns zero... if I graph it I can see it's literally been zero for days even though this is not the case.
processor_performance is more related to power scaling, rather than usage. If it is zero, it is possible your CPU isn't exposing that data to Windows.
What you are probably looking for is something like sum(rate(windows_cpu_time_total{mode!="idle"}[5m])) by (core).
Thanks @carlpett I thought I might have misunderstood it - I had assumed one of the metrics directly matched CPU% in task-manager!
If that's what I want to emulate - users aren't going to understand CPU time but they do understand "80%" would it be as simple as dividing the change in CPU time by the rate-interval? I'd like to display CPU and RAM utilisation rather than raw numbers, bascally (can raise a new issue if that's neater as you have answered the specific question)
sum(rate(windows_cpu_time_total{mode!="idle"}[5m])) by (core) will give you the "average number of cpu seconds per second" over the chosen interval (5m here). That basically maps to the usage ratio, though perhaps not an intuitive way to phrase it. It might help to think about it like a 30% utilization meaning that you do active computation on 0.3 seconds every second?
So 100*sum(rate(windows_cpu_time_total{mode!="idle"}[5m])) by (core) would give you the usage percentage (or if you use Grafana you can just set it to use a 0-1 ratio rather than 0-100).
For the memory part, it's quite straightforward, as you have windows_cs_physical_memory_bytes and windows_memory_available_bytes and just divide.
Ah, I knew I was doing something wrong when testing this, I'd forgotten rate automatically went back into "per second".
I think this solves my issue so I'll close - many thanks for your help.
Most helpful comment
sum(rate(windows_cpu_time_total{mode!="idle"}[5m])) by (core)will give you the "average number of cpu seconds per second" over the chosen interval (5m here). That basically maps to the usage ratio, though perhaps not an intuitive way to phrase it. It might help to think about it like a 30% utilization meaning that you do active computation on 0.3 seconds every second?So
100*sum(rate(windows_cpu_time_total{mode!="idle"}[5m])) by (core)would give you the usage percentage (or if you use Grafana you can just set it to use a 0-1 ratio rather than 0-100).For the memory part, it's quite straightforward, as you have
windows_cs_physical_memory_bytesandwindows_memory_available_bytesand just divide.