Skip to content
Related Articles

Related Articles

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

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 20 Jan, 2022

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 

| where Origin == ""
 and Namespace == "LogicalDisk" and Name == "FreeSpacePercentage"
| extend Disk=tostring(todynamic(Tags)[""])
| 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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!