Azure Monitor monitors CPU utilization of windows system
If we have not previously enabled performance counter data, we can click Advanced Settings in Log Analytics Workspace, click data, now click Windows performance counters, and finally click add selected performance counters:
Query the collected data
We can use the following query statement to query the CPU utilization of the system from the data we have collected:
Perf | where ObjectName = "Processor" and CounterName = "% Processor Time" and InstanceName = = "_ Total" and Computer in ((Heartbeat | distinct Computer)) | summarize PCT95CPUPercentTime = percentile (CounterValue, 95) by Computer | summarize max (PCT95CPUPercentTime) by Computer | join (Perf | where ObjectName = = "Processor" and CounterName = "% Processor Time" and InstanceName = "_ Total" and Computer in ((Heartbeat | distinct Computer)) on Computer | make-series PCT95CPUPercentTime = percentile (CounterValue, 95) on TimeGenerated from ago (5h) to now () step 10m by Computer | by Computer
You can also use the following statement to view machines whose CPU usage is greater than a certain value:
Let setpctValue = 3Perf | where ObjectName = = "Processor" and CounterName = = "% Processor Time" and InstanceName = = "_ Total" and Computer in ((Heartbeat | distinct Computer)) | summarize PCT95CPUPercentTime = percentile (CounterValue, 95) by Computer | where PCT95CPUPercentTime > setpctValue | summarize max (PCT95CPUPercentTime) by Computer | join (Perf | where ObjectName = = "Processor" and CounterName = "% Processor Time" and InstanceName = = "Total" and Computer in ((Heartbeat | distinct Computer)) on Computer | make-series PCT95CPUPercentTime = percentile (CounterValue, 95) on TimeGenerated from ago (5h) to now () to now 10m step |
Fix the performance chart to the dashboard
To pin the chart we have queried to Azure Dashboard, click the "fixed" button at the top right of the query window, and then select the Dashboard in which we want to display the icon.