Fetch processes with Names by CPU Usage for AVD Machines using Azure Log Analytics or Azure Monitoring

Hirdesh Baghel 20 Reputation points
2024-10-03T03:53:26.53+00:00

Hi

I am trying to fetch the process which are consuming CPU usage in %, For this I am using Azure Log Analytics. I found some of the KQL queries to fetch CPU and Memory utilization but they are not giving info regarding the process like which process is consuming more CPU.

Sample query:

Perf

| where (ObjectName == "Processor" and CounterName == "% Processor Time" and InstanceName == "_Total") or (ObjectName == "Memory" and CounterName == "Available MBytes")
| summarize avg(CounterValue) by TimeGenerated, ObjectName, CounterName, InstanceName

| project TimeGenerated, ObjectName, CounterName, InstanceName, CounterValue = avg_CounterValue


User's image

Is there is any way to achieve the above requirement?

Kindly help!

Thanks

Hirdesh

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,310 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,981 questions
Azure Virtual Desktop
Azure Virtual Desktop
A Microsoft desktop and app virtualization service that runs on Azure. Previously known as Windows Virtual Desktop.
1,565 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshukatara-6769 10,210 Reputation points
    2024-10-03T05:15:21.7266667+00:00

    Hello Hirdesh, Welcome to MS Q&A

    To fetch the process consuming more CPU in Azure Log Analytics, you can use the Perf table and filter on the CounterName column to find the process consuming the most CPU. Here's an example KQL query to achieve this: You can try this once and let us know

    Perf
    | where ObjectName == "Process" and CounterName == "% Processor Time" and InstanceName != "_Total"
    | summarize avg(CounterValue) by InstanceName, bin(TimeGenerated, 1m)
    | order by avg_CounterValue desc
    
    
    

    This query will return the processes consuming the most CPU, ordered by the average CPU usage over the last minute. You can adjust the bin function to change the time interval over which the average is calculated.

    References:

    Please let us know if any questions

    Kindly accept answer if it helps

    Thanks

    Deepanshu


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.