Monitor free disk space on Azure VM

后端 未结 3 1377
一生所求
一生所求 2021-01-04 01:56

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.

3条回答
  •  孤独总比滥情好
    2021-01-04 02:20

    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, ) 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
    

提交回复
热议问题