在Azure虚拟机上监控可用磁盘空间

28

有没有办法从Azure门户监视可用磁盘空间?

我知道有各种诊断工具,如I/O、内存、网络、CPU、.NET、SQL、ASP.NET、IIS等。

但是否有一种方法可以查看与VM连接的磁盘上有多少可用空间?

我找到的只有这个第三方解决方案:

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

但应该有一些基本的度量标准,如磁盘空间,而不需要第三方软件,对吗?

4个回答

21

2019年更新

现在已经可以实现。要使用 Azure Monitor 监视每个驱动器的免费磁盘空间,请执行以下操作:

  1. 为 VM 启用客户操作系统 OS 指标
  2. Azure 门户中选择虚拟机。
  3. 单击诊断设置(位于“监视”下方)。
  4. 单击性能计数器选项卡。
  5. 单击自定义按钮。
  6. 在文本框中添加所需驱动器的自定义指标,例如 \LogicalDisk(C:)\% Free Space
  7. 单击添加并将单位设置为 百分比

来源:Azure 支持。


若要查看 Linux 的 Azure Guest Monitor 日志:

// 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

这将导致以下警报查询(您需要在查询中使用AggregatedValuebin(TimeGenerated,<some time>)):

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

查看任何通用诊断端点的方法(感谢 @gabe):

打开此选项后,我可以通过日志查询查看可用的磁盘空间:


// 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

2
打开此功能后,我能够使用日志查询查看可用的磁盘空间://虚拟机剩余磁盘空间 //显示每个实例的最新免费磁盘空间报告 Perf | where ObjectName == "LogicalDisk" or // Windows 记录中使用的对象名称 ObjectName == "Logical Disk" // Linux 记录中使用的对象名称 | where CounterName == "Free Megabytes" | summarize arg_max(TimeGenerated, *) by InstanceName // arg_max over TimeGenerated returns the latest record | project TimeGenerated, InstanceName, CounterValue - gabe
确实非常有帮助。您可以告诉我如何使用ARM实现它吗? - ARINDAM BANERJEE
我无法从这些查询中看到任何输出。我认为你需要启用应用程序洞察才能运行其中一个,但对于 @gabe 的查询来说不应该需要,对吗? - Dhruv Kapoor
1
2021年这个答案对于Linux虚拟机来说并不足够,没有“性能计数器”选项卡,我无法按照这些步骤添加任何指标。 - Mirek

2

目前在Azure门户上还不可能实现。

但是您可以使用Azure OMS来实现。这里有一个示例,介绍如何使用Azure OMS监控可用磁盘空间。


4
一年后还是不可能吗? - eddyP23
你能提供一些逐步的示例来说明如何做到这一点吗?两篇文章都不太清楚如何针对每个磁盘进行操作。 - Hans Vonn
1
三年后还是不可能吗? - Lucas Hendren
1
四年后呢? - Will
现在怎么样? - WhiteProfileSpecialist

2
今天无法通过Azure门户或Azure Monitor实现此功能。空闲磁盘空间是一个客户操作系统性能计数器。如果这是Windows VM,您可以使用Windows Azure诊断(WAD)代理程序收集性能计数器并将其设置到Azure Storage表和/或EventHub,并设置自定义工具来监视此数据。如果这是Linux VM,则也有相应的Linux诊断扩展程序。
以下是一些关于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


1

在Azure门户中是可以实现的。在VM资源页面中,选择Logs blade并搜索“free disk”。您将得到一个默认查询,可以运行以获取磁盘使用情况。 您可以将此查询固定到仪表板或将其发送到工作簿以经常检查使用情况。

参考 - Microsoft Techcommunity


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接