0

I wanted to get the performance report of my azure VMs using log analytics. I found a blog here

which shows what I wanted.

The problem is when I run the code in my log analytics, it gives all the details except FreeMemoryGB and TotalMemoryGB as shown in the screenshot in the blog. It just shows blank space.

Thanks

  • You can refer to [Is there any API to query an Azure VM for free disk/memory space?](https://stackoverflow.com/questions/58501252/is-there-any-api-to-query-an-azure-vm-for-free-disk-memory-space), [Azure Free Space metric does not show any data](https://stackoverflow.com/questions/67164853/azure-free-space-metric-does-not-show-any-data?rq=1) and [some of Azure virtual machine custom performance counters are not being collected in log analytics](https://stackoverflow.com/questions/58338997/some-of-azure-virtual-machine-custom-performance-counters-are-not-being-collecte?rq=1) – Ecstasy Nov 18 '21 at 06:39
  • 1
    Its has to do something with used memory. when i ran this query it gave me nothing: let UsedMemory = Perf | where TimeGenerated > now(-60min) and (ObjectName == "Memory" and CounterName == "Committed Bytes") | summarize UsedMemory = (avg(CounterValue)) by bin(TimeGenerated, 1h), Computer, InstanceName | sort by TimeGenerated, Computer desc; UsedMemory – Biswajeet Kumar Nov 18 '21 at 07:09
  • For Windows "% Committed Bytes In Use" is the closest which can give you the current memory in use for any windows VM. https://stackoverflow.com/a/59262644 – Ecstasy Nov 18 '21 at 07:22
  • Ok, What about Total memory of the VM. Is there any counter or way to query that. – Biswajeet Kumar Nov 18 '21 at 07:25
  • `CounterName == "% Free Space"` `InstanceName == "_Total"` https://stackoverflow.com/a/58541011/15969115 – Ecstasy Nov 18 '21 at 07:30
  • Not the disk but RAM memroy. – Biswajeet Kumar Nov 19 '21 at 04:17
  • You can refer to [Physical memory or RAM usage in Percentage](https://techcommunity.microsoft.com/t5/azure-monitor/physical-memory-or-ram-usage-in-percentage/m-p/762664), [RAM usage alert by log analytics | Azure](https://superuser.com/questions/1531228/ram-usage-alert-by-log-analytics-azure) and [How to Monitor RAM Size](https://techcommunity.microsoft.com/t5/azure/how-to-monitoring-ram-size/m-p/2091470) – Ecstasy Nov 19 '21 at 04:24

1 Answers1

0

Thank you Arun and KrishnaG-MSFT. Posting your suggestions as an answer to help other community members.

"% Used Memory" is a counter available for Linux boxes only. For Windows "% Committed Bytes In Use" is the closest which can give the current memory in use for any windows VM.

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

If your Azure VM is Windows OS then query to find disk total free space is:

Perf
| where ( ObjectName == "LogicalDisk" )
| where ( CounterName == "% Free Space" )
| where ( InstanceName == "_Total" )
| summarize AggregatedValue= avg(CounterValue) by Computer, bin(TimeGenerated, 30s)

You can refer to Read Windows VM RAM Memory Log Analytics Query and Is there any API to query an Azure VM for free disk/memory space?

Ecstasy
  • 1,866
  • 1
  • 9
  • 17
  • What I want is how much memory has been used which I got but also how much memory it has in total in GB. So that I can compare. – Biswajeet Kumar Nov 19 '21 at 05:16
  • [Log Analytics Metrics/Counter for Memory & CPU Load](https://techcommunity.microsoft.com/t5/azure-monitor/log-analytics-metrics-counter-for-memory-amp-cpu-load/m-p/1420896) and [Collect Windows and Linux performance data sources with Log Analytics agent](https://learn.microsoft.com/en-us/azure/azure-monitor/agents/data-sources-performance-counters) – Ecstasy Nov 19 '21 at 05:46
  • ok, I see there is no counter for getting total RAM. – Biswajeet Kumar Nov 19 '21 at 11:44
  • [How to find total size of each disk attached to Azure Linux Virtual Machine from Azure Log analytics?](https://stackoverflow.com/a/69026917) – Ecstasy Nov 19 '21 at 12:02
  • I think log analytics does not provide VM configs like how much RAM, CPU, Disk config name has been assigned to any VM. – Biswajeet Kumar Nov 26 '21 at 06:32
  • [Using Azure Log Analytics Workspaces to collect Custom Logs from your VM](https://towardsdatascience.com/using-azure-log-analytics-workspaces-to-collect-custom-logs-from-your-vm-99ef7816a0fe) – Ecstasy Nov 26 '21 at 06:36