Monitor free disk space on Azure VM
Asked Answered
S

4

29

Is there some way how to monitor free disk space from the Azure Portal?

I know that there are all kinds of diagnostics for I/O, memory, network, CPU, .NET, SQL, ASP.NET, IIS, etc.

But is there some way to see how much free space there's on a disk attached to the VM?

All I found was this third-party solution:

http://cloudmonix.com/blog/how-to-monitor-free-disk-space-on-azure-vms/

But there should be some way how to see a basic metric like disk space without needing third-party SW, right?

Spectrogram answered 17/3, 2017 at 9:15 Comment(0)
S
21

Update 2019

This is possible today. To monitor free disk space per drive with Azure Monitor do the following:

  1. Enable Guest Operating System OS Metrics for the VM.
  2. In the Azure Portal select the Virtual Machine.
  3. Click Diagnostics Settings (under Monitoring).
  4. Click the Performance counters tab.
  5. Click the Custom button.
  6. In the textbox add the custom metric for the drive you would like. e.g. \LogicalDisk(C:)\% Free Space.
  7. Click Add and set the Unit to Percent.

Source: Azure Support.


To view the logs from the Azure Guest Monitor for Linux:

// Virtual Machine free disk space
// Show the latest report of free disk space, per instance
InsightsMetrics
| where Name == "FreeSpacePercentage"
| summarize arg_max(TimeGenerated, *) by Tags
// arg_max over TimeGenerated returns the latest record
| project TimeGenerated, Computer, Val, Tags

This results in the following alert query (you need AggregatedValue and bin(TimeGenerated, <some time>) in the query):

InsightsMetrics
| where Name == "FreeSpacePercentage"
| summarize AggregatedValue=arg_min(Val, *)  by bin(TimeGenerated, 5min), Tags

To view the same for any generic diagnostics endpoint (thanks @gabe):

After turning this on, i was able to view the free disk space with a log query:

// Virtual Machine free disk space 
// Show the latest report of free disk space, per instance 
Perf 
 | where ObjectName == "LogicalDisk" or 
// the object name used in Windows records 
  ObjectName == "Logical Disk" // the object name used in Linux records 
 | where CounterName == "Free Megabytes" 
 | summarize arg_max(TimeGenerated, *) by InstanceName 
// arg_max over TimeGenerated returns the latest record 
 | project TimeGenerated, InstanceName, CounterValue
Stephaniastephanie answered 28/2, 2019 at 15:36 Comment(5)
after turning this on, i was able to view the free disk space with a log query: // Virtual Machine free disk space // Show the latest report of free disk space, per instance Perf | where ObjectName == "LogicalDisk" or // the object name used in Windows records ObjectName == "Logical Disk" // the object name used in Linux records | where CounterName == "Free Megabytes" | summarize arg_max(TimeGenerated, *) by InstanceName // arg_max over TimeGenerated returns the latest record | project TimeGenerated, InstanceName, CounterValueEquidistant
It's very helpful indeed. Can you please tell me how to achieve it using ARM?Stahl
I'm not able to see any output from these queries. I assume you need App Insights enabled to run the one but it shouldn't be needed for @gabe's query, right?Mikemikel
2021 this answer is not sufficient for linux VM, there is no "Performance counters" tab and I can't really add any metric with these stepsAureliaaurelian
I don't see the option "custom" in a scale set, correct?Fatness
M
2

For now, it is not possible on Azure Portal.

But you could do it by using Azure OMS. There is a example how to use Azure OMS to monitor free disk.

Microsporangium answered 17/3, 2017 at 9:34 Comment(5)
Still not possible a year later?Houselights
Can you provide some step by step examples of how to do this? Both articles are a little unclear as how to do this per disk.Stephaniastephanie
Is it still not possible 3 years later?Busload
What about 4 years later?Vaginismus
What about now?Echinate
C
2

This is not possible today through Azure Portal or Azure Monitor. Free disk space is a guest OS performance counter. If this is a Windows VM, you can use the Windows Azure Diagnostics (WAD) agent to collect performance counters to either Azure Storage table and/or EventHub and setup custom tool to monitor this data. If this is a Linux VM, there is also the equivalent Linux Diagnostic Extension.

Here are some relevant links on WAD -

https://learn.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-extensions-diagnostics-template?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/azure-diagnostics-streaming-event-hubs

Choreography answered 25/3, 2017 at 3:6 Comment(0)
P
1

This is possible in Azure portal. In the VM resource page select the Logs blade and search "free disk". You'll get a default query which can be run to get the disk usage. You can pin this query to dashboard or send it to workbook to check the usage frequently.

Reference - Microsoft Techcommunity

Prototrophic answered 21/4, 2022 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.