Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello, I am looking to improve upon an example query that outputs free disk percentage for an Azure machine. I would like for it to also display in the project the used percentage instead of free percentage, used disk space (in GB), and total disk space. AI hasn't been so fortunate in giving any correct syntax/variables/etc.
Thank you
InsightsMetrics
| where Namespace == "LogicalDisk"
| where Name == "FreeSpacePercentage"
| extend Disk=tostring(todynamic(Tags)["vm.azm.ms/mountId"])
| summarize arg_max(TimeGenerated, *) by Disk, Computer
| extend TimeGenerated_EST = datetime_utc_to_local(TimeGenerated, 'America/New_York')
| project TimeGenerated_EST, Disk, Computer, Val
| where Val > 30
This is a query I saved (source: https://stackoverflow.com/questions/76372077/how-to-find-both-disk-size-and-disk-space-used-in-azure). It calculates the size but should be close enough in most cases, you'll just have to calculate the used % from this
InsightsMetrics
| where Namespace == "LogicalDisk"
| where Name in ("FreeSpaceMB", "FreeSpacePercentage")
| extend Disk=tostring(todynamic(Tags)["vm.azm.ms/mountId"])
| summarize arg_max(TimeGenerated, Val) by Computer, Name, Disk, _ResourceId
| extend Packed = bag_pack(Name, Val)
| project TimeGenerated, Computer, Disk, _ResourceId, Packed
| summarize Packed = make_bag(Packed) by TimeGenerated, Computer, Disk, _ResourceId
| evaluate bag_unpack(Packed) : (TimeGenerated:datetime , Computer:string, Disk:string, _ResourceId:string, FreeSpaceMB:long, FreeSpacePercentage:decimal)
| extend DiskSizeGB = ceiling((todecimal(FreeSpaceMB) / (FreeSpacePercentage / todecimal(100))) /1024)
| extend freeSpaceGB = FreeSpaceMB /1024