Forum Discussion
david1718
Mar 21, 2022Copper Contributor
Creat a query to get CPU usage from every process on the VM
Hi,
I'm trying to get the CPU usage from every process on my vm is that possible with log analytics? I can't seem to get it. It seems I need to convert the counter value i'm getting to percentage usage but I can't find the way to do it.
This is what I have until now.
Perf
| where TimeGenerated > now(-30m)
and ObjectName == "Process"
and CounterName == "% Processor Time"
and InstanceName != "_Total"
and InstanceName != "Idle"
and CounterValue > 5
| project Computer, ObjectName, CounterName, InstanceName, CounterValue, TimeGenerated
4 Replies
- Clive_WatsonBronze Contributor
CounterValue is a % (percentage), so for this Computer, here are the top 10 counters over 5% (which you defined), the top one being 14.4%.
Perf | where TimeGenerated > now(-30m) | where Computer startswith "SQL01" and ObjectName == "Process" and CounterName == "% Processor Time" and InstanceName != "_Total" and InstanceName != "Idle" and CounterValue > 5 | project Computer, ObjectName, CounterName, InstanceName, CounterValue, TimeGenerated | top 10 by CounterValue | order by CounterValue descGo to Log Analytics and run query
- david1718Copper Contributor
- Clive_WatsonBronze Contributor
Perf | where TimeGenerated > now(-30m) | where Computer startswith "SQL01" and ObjectName == "Process" and CounterName == "% Processor Time" and InstanceName != "_Total" and InstanceName != "Idle" and CounterValue > 5 | summarize TotalCPU = sum(CounterValue), avgCPU = avg(CounterValue) by InstanceName,Computer | order by TotalCPU desclike this?