微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

当我的虚拟机磁盘空间不足时如何创建 azure 监视器警报

如何解决当我的虚拟机磁盘空间不足时如何创建 azure 监视器警报

我有一台虚拟机。现在我想如果我的磁盘空间显示非常低我的意思是小于 2 GB。然后我想触发 azure 监视器警报并希望收到有关此的电子邮件。是否有任何指标 azure 监视器提供。

解决方法

截至目前,没有针对磁盘空间的预定义警报。但您可以使用自定义日志搜索创建新警报以获取详细信息,然后触发向您发送电子邮件。

第 1 步:转到监控页面上的警报,然后点击新建警报规则。

enter image description here

第 2 步:然后选择资源,并在此处按资源选择您已启用 VM 监控的日志分析工作区。就我而言,它是 TestLog。

enter image description here

第 3 步:现在选择自定义日志搜索。

enter image description here

第 4 步:然后在搜索查询框中提供我在下面提供的自定义查询,您可以根据您的要求将阈值设置为“0”以及以分钟为单位的周期和频率例如,我将其设置为 60 分钟。

enter image description here

第 5 步:现在选择一个现有的操作组,或者您可以通过点击新建并填写详细信息来创建一个新的操作组。创建后,单击操作组并将通知类型添加为电子邮件或您要指定的任何内容。

enter image description here

enter image description here

第 6 步:填写其余详细信息,例如电子邮件主题和要设置的警报的严重性,然后创建警报。

enter image description here

自定义查询:

let setgbvalue = 200;//Set the disk space you want to check for. 

 Perf 

 | where TimeGenerated > ago(1h)

 | where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes" 

// exclude all others as we are checking for C: here 

 | where InstanceName != "D:"  

 | where InstanceName  != "_Total" 

 | where InstanceName != "HarddiskVolume1" 

 | extend FreeSpaceGB = CounterValue/1024 // converting the counter value to GB 

 | summarize FreeSpace = min(FreeSpaceGB) by Computer,InstanceName 

 | where FreeSpace < setgbvalue //setting condition to check if the value is less than our set value . 

enter image description here

示例:

为了测试它,我将值设置为 200GB,我的磁盘空间为 106GB。我收到了如下邮件。

enter image description here enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。