KQL query to disk space utilization in GB and server uptime

%3CLINGO-SUB%20id%3D%22lingo-sub-1164014%22%20slang%3D%22en-US%22%3EKQL%20query%20to%20disk%20space%20utilization%20in%20GB%20and%20server%20uptime%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1164014%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20looking%20for%20KQL%20query%20to%20check%20%3CSTRONG%3EDisk%20space%20utilization%3C%2FSTRONG%3E%26nbsp%3Bin%20GB(14h)for%20every%20VM%20hosted%20on%20azure%20in%20and%20also%20looking%20for%20KQL%20query%20to%20check%20%3CSTRONG%3Eserver%20up-time%3C%2FSTRONG%3E%20for%20past%2014h.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%20!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1164014%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1164329%22%20slang%3D%22en-US%22%3ERe%3A%20KQL%20query%20to%20disk%20space%20utilization%20in%20GB%20and%20server%20uptime%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1164329%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F485201%22%20target%3D%22_blank%22%3E%40Prince0103%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20uptime%20you%20have%20the%20built-in%20example%20-%20its%20called%20%22Availability%20Rate%22%20you%20see%20it%20when%20you%20open%20a%20new%20Query%20Tab.%26nbsp%3B%20This%20is%20for%20the%20Agent%20uptime%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%2F%2F%20Availability%20rate%0A%2F%2F%20Calculate%20the%20availability%20rate%20of%20each%20connected%20computer%0AHeartbeat%0A%2F%2F%20bin_at%20is%20used%20to%20set%20the%20time%20grain%20to%201%20hour%2C%20starting%20exactly%2024%20hours%20ago%0A%7C%20summarize%20heartbeatPerHour%20%3D%20count()%20by%20bin_at(TimeGenerated%2C%201h%2C%20ago(24h))%2C%20Computer%0A%7C%20extend%20availablePerHour%20%3D%20iff(heartbeatPerHour%20%26gt%3B%200%2C%20true%2C%20false)%0A%7C%20summarize%20totalAvailableHours%20%3D%20countif(availablePerHour%20%3D%3D%20true)%20by%20Computer%20%0A%7C%20extend%20availabilityRate%20%3D%20totalAvailableHours*100.0%2F24%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESystem%20Uptime%20is%20also%20a%20Perf%20counter%20-%20like%20this%20(if%20yuou%20are%20collecting%20this%20counter)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EPerf%0A%7C%20where%20ObjectName%20%3D%3D%20%22System%22%20and%20CounterName%20%3D%3D%20%22System%20Up%20Time%22%0A%7C%20extend%20UpTime%20%3D%20CounterValue%20*%201s%0A%7C%20summarize%20arg_max(TimeGenerated%2C%20*)%20by%20Computer%0A%7C%20project%20Computer%2C%20UpTime%2C%20TimeGenerated%0A%7C%20sort%20by%20Computer%20asc%0A%20%7C%20project%20Computer%2C%20UpTime%2C%20TimeGenerated%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CDIV%20id%3D%22tinyMceEditorClive%20Watson_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20disk%20space%20please%20start%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-log-analytics%2Fhelp-with-disk-query-in-log-analytics%2Fm-p%2F160239%23M440%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-log-analytics%2Fhelp-with-disk-query-in-log-analytics%2Fm-p%2F160239%23M440%3C%2FA%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorClive%20Watson_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I am looking for KQL query to check Disk space utilization in GB(14h)for every VM hosted on azure in and also looking for KQL query to check server up-time for past 14h.

 

Any help would be appreciated.

 

Thanks in advance !!

1 Reply
Highlighted

@Prince0103 

 

For uptime you have the built-in example - its called "Availability Rate" you see it when you open a new Query Tab.  This is for the Agent uptime 

 

// Availability rate
// Calculate the availability rate of each connected computer
Heartbeat
// bin_at is used to set the time grain to 1 hour, starting exactly 24 hours ago
| summarize heartbeatPerHour = count() by bin_at(TimeGenerated, 1h, ago(24h)), Computer
| extend availablePerHour = iff(heartbeatPerHour > 0, true, false)
| summarize totalAvailableHours = countif(availablePerHour == true) by Computer 
| extend availabilityRate = totalAvailableHours*100.0/24

 

System Uptime is also a Perf counter - like this (if yuou are collecting this counter)

 

Perf
| where ObjectName == "System" and CounterName == "System Up Time"
| extend UpTime = CounterValue * 1s
| summarize arg_max(TimeGenerated, *) by Computer
| project Computer, UpTime, TimeGenerated
| sort by Computer asc
 | project Computer, UpTime, TimeGenerated
 

 

For disk space please start here: https://techcommunity.microsoft.com/t5/azure-log-analytics/help-with-disk-query-in-log-analytics/m-p...