1
votes

I've been working on Log Analytics Workspace query, there i'd like to know about the memory(RAM) being use by windows VM Specially, in linux vm we can get it from % Used Memory counter though not able yo get Windows VM. Query for Linux Used memory is shown below:

// Memory usage
Perf
| where TimeGenerated > ago(30m)
| where  CounterName == "% Used Memory" 
| project TimeGenerated, CounterName, CounterValue, Computer
| summarize UsedMemory = avg(CounterValue) by CounterName, bin(TimeGenerated, 1m), Computer
| where UsedMemory > 20 
| render timechart
2

2 Answers

1
votes

this would work pretty much the same for windows vms, but you need to configure which counters do you gather, before this query can work.

https://docs.microsoft.com/en-us/azure/azure-monitor/platform/data-sources-performance-counters#configuring-performance-counters

0
votes

@Sachin : You are right. "% Used Memory" is a counter available for Linux boxes only. For Windows "% Committed Bytes In Use" is the closest which can give you the current memory in use for any windows VM. The query can be the same what you have written but with the different counter name

Perf
| where TimeGenerated > ago(30m)
| where  CounterName == "% Committed Bytes In Use" 
| project TimeGenerated, CounterName, CounterValue, Computer
| summarize UsedMemory = avg(CounterValue) by CounterName, bin(TimeGenerated, 1m), Computer
| where UsedMemory > 20 
| render timechart