Need to fetch VM CPU, Memory & Disk usage that are less than 50%

Microsoft

Hi Team,

 

I have configured all the vms in Loganalytics.

Enabled diagnostic setting and insights for the vm.

 

I need a Kusto Query to fetch VM CPU, Memory & Disk usage that are less than 50% for last 1 month.

Tired few queries by running in Loganalytics --> "Logs". failed to get the output.

With the help of the report, we want to recommend customer to resize the vm.

2 Replies

@brijohn if you type disk, memory or cpu in the queries tab there are loads of examples. Do none of these work, if so is there any data in the tables? 

Hello @brijohn ,

 

One of the factor is to define what is considered to be a threshold violation.

Example: A CPU that reaches 95% over a period of 20 seconds is not necessarily a issue if its average over 1 minute is at 7%.

 

//% CPU usage:
Perf
| where Computer == "YourVM-Name"
| where ObjectName == 'Processor' and CounterName == '% Processor Time' and InstanceName == '_Total'
| summarize AvgCPUPct=avg(CounterValue) by bin (TimeGenerated, 5m)
| render timechart title = "% CPU usage (bin to 5min)"

 

//Committed Bytes in use % (Virtual + Physical Memory):
Perf
| where Computer == "YourVM-Name"
| where ObjectName == "Memory" and CounterName == "Available MBytes"
| summarize AvgAvailableRAM = avg(CounterValue/1024) by bin (TimeGenerated, 5m)
| project AvgAvailableRAM, TimeGenerated

 

//Disk Queue Length:
Perf
| where Computer == "YourVM-Name"
| where ObjectName == "PhysicalDisk" and CounterName == "Avg. Disk Queue Length" and InstanceName contains "_Total"
| summarize AvgDQ=avg(CounterValue) by bin (TimeGenerated, 5m)
| project AvgDQ, TimeGenerated