- 1 year ago
Azure Log Analytics Query for CPU performace stats by each process
To get CPU performance stats by each process in Azure Log Analytics, you can use the following query:
csharpPerf
| where ObjectName == "Process" and CounterName == "% Processor Time"
| where InstanceName != "_Total"
| summarize avg(CounterValue) by InstanceName, bin(TimeGenerated, 5m)
| sort by avg_CounterValue desc
In this query, we use the Perf
table to retrieve performance data for the "Process" object and the "% Processor Time" counter. We filter out the "_Total" instance, as we want to see data for each individual process. We then use the summarize
operator to calculate the average CPU usage for each process, grouped by the InstanceName
(which corresponds to the process name). We also use the bin
function to group the results by 5-minute intervals. Finally, we sort the results by the average CPU usage in descending order.
This query will give you a list of processes and their average CPU usage over the specified time period (in this case, 5-minute intervals). You can modify the bin
function to adjust the time interval as needed.