Forum Discussion
Azure Monitor disk space used report
Hi,
I need some help creating a KQL query that shows the disk space used. The query would need to output something similar to the VM insights report that shows the current disk size and the disk space used.
I have a query for free disk space but I'll need a query for used disk space so I can create an alert from the query.
Thanks,
D
6 Replies
- PradeepDeivaCopper Contributor
Try this
InsightsMetrics | where Origin == "vm.azm.ms" and Namespace == "LogicalDisk" and Name == "FreeSpacePercentage" | extend Disk=tostring(todynamic(Tags)["vm.azm.ms/mountId"]) | summarize Disk_Free_Space = avg(Val) by Computer, Disk, _ResourceId | project Computer, Disk, Disk_Free_Space
- DSM4201Copper Contributor
Hi, thanks for the script but I'm looking for one that show's the disk's used space. I noticed this thread (https://techcommunity.microsoft.com/t5/azure-observability/help-with-disk-query-in-log-analytics/m-p/160239#M440) mentioning using a calculation to find the used space but they were also having issues with the query.
Do you know if I can use another calculation to find the % UsedSpace?
Thanks.
- PradeepDeivaCopper Contributor
yea , for Linux - % free space and for Windows - %used space are not direct
check this link - https://www.catapultsystems.com/blogs/calculating-total-memory-and-total-disk-space-in-log-analytics/try adding a last column with the values got from free space and total size - we can calculate the %
hope this helps