Forum Discussion
JoseO1335
Oct 23, 2024Copper Contributor
Azure Monitor Alert for low disk space percent and MB
Hello, I am trying to create a KQL query that will alert me if the diskspace percentage exceeds a percentage threshold. But I also want the alert to show how much used space and free space is lef...
Kidd_Ip
Nov 11, 2024MVP
Try follow, make sure you are fully understood before apply:
InsightsMetrics
| where Origin == "vm.azm.ms"
| where Namespace == "LogicalDisk" and (Name == "FreeSpacePercentage" or Name == "FreeSpaceMB" or Name == "CapacityMB")
| summarize
LogicalDiskSpacePercentageFreeAverage = avg(iif(Name == "FreeSpacePercentage", Val, 0)),
FreeSpaceMB = avg(iif(Name == "FreeSpaceMB", Val, 0)),
CapacityMB = avg(iif(Name == "CapacityMB", Val, 0))
by bin(TimeGenerated, 15m), Computer, _ResourceId
| extend UsedSpaceMB = CapacityMB - FreeSpaceMB
| where LogicalDiskSpacePercentageFreeAverage < 20 // Threshold example for disk space percentage
| project TimeGenerated, Computer, _ResourceId, LogicalDiskSpacePercentageFreeAverage, FreeSpaceMB, UsedSpaceMB