Open In App

Microsoft Azure – Azure VM Disk Space in Percentage using Azure KQL

Improve
Improve
Like Article
Like
Save
Share
Report

Here we’ll be using the Azure Insights Metric Query to find the free disk space in percentage using KQL. The purpose of this query is to find disk drive free space of all the Azure VMs without logging into every server. You can Run the following KQL log Queries in Azure Monitor or Azure VM Logs or Log Analytics Workspace.

Note: VM Insights Agent should be enabled for the Azure VM to use these queries.

KQL Query: The following query is used to find the free disk in percentage 

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

this query returns the result of Select Computer from Scope, Disk Drive Name, and Free Disk in Percentage.

The following sample is for Azure Windows Server:

Sample Output for Window Virtual Machine

You can use the same KQL Query for Linux Virtual Machine also.

Sample Output for Linux Virtual Machine

That’s it! This was a simple way to check the available disk space in percentage on an azure VM using KQL.


Last Updated : 30 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads