Is there a way to get both disk sizes and disk space used in azure?
I can use a query like this and get the percentage or mb used
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
And see disk sizes like this
resources
| where type == "microsoft.compute/disks"
| project properties['diskSizeGB']
But is there a way to see both size of disk and how much space is left?
2
Answers
This query would give you an approximation disk size, though it will never be 100% accurate, but very close
Another way you could calculate it is by taking your two original queries and using Azure Workbooks to query Log Analytics and Azure Resource Graph and then merge the results https://learn.microsoft.com/en-us/azure/azure-monitor/visualize/workbooks-data-sources#merge
You can use below
Kusto Query Language
that retrieves both the disk sizes and used disk space also free space for each disk.KQL Query:
Output: