Query for Percent Memory Used

Copper Contributor

Hi Guys,

Can someone give me the azure log analytics Query which will provide me the Memory (RAM) usage in percentage (Percent Memory Used) of all Virtual machines.

3 Replies

@roopesh_shetty 

 

There is an example on the logs home page

Annotation 2019-06-06 195310.jpg

 

It does have CPU info as well, but if you edit that out you have:

 

// Memory usage
// Chart all computers' used memory  over the last hour
Perf
| where TimeGenerated > ago(1h)
| where  CounterName == "% Used Memory" 
| project TimeGenerated, CounterName, CounterValue 
| summarize avg(CounterValue) by CounterName, bin(TimeGenerated, 1m)
| render timechart

Note: you have to collect "% Used Memory"  in log Analytics https://docs.microsoft.com/en-us/azure/azure-monitor/platform/data-sources-performance-counters

@CliveWatson From what I understand, this does not work for Windows VMs, since they do not have the "% Used Memory" performance counter.

@roopesh_shetty, you can use:
Perf
| where ObjectName == "Memory" and CounterName == "% Committed Bytes In Use"
| summarize AvgMemoryUsage = avg(CounterValue) by bin(TimeGenerated, 1hr), Computer
| render timechart with (title = "Memory Utilization", xtitle = "Time", ytitle = "Value", ymax=100)