Forum Discussion
lobryan2023
Sep 06, 2023Copper Contributor
Looking for VM Availability Percentage
I'm trying to make a logic app that will report the percentage availability of all of my VMs over a week. I have a log analytics query that gives me the availability of each server over a week, but I'm looking to get the average of all the servers. Here's the query I have:
Heartbeat
| where Computer has ""
| where TimeGenerated > ago(7d)
| summarize heartbeatPerHour = count() by bin_at(TimeGenerated, 1m, ago(1d)), Computer
| extend AvailablePerHour = iff(heartbeatPerHour > 0, true, false)
| summarize TotalAvailableMinutes = countif(AvailablePerHour == true) by Computer
| extend AvailabilityRate = round(TotalAvailableMinutes*100.0/10080, 3)
What I need to do get the average of the "AvailabilityRate". I would like to build this in a logic app to run once a week. I currently have a logic app built with a weekly trigger to run the above query, list the results, create HTML table, and send an email. What I'd like to have in addition to the table in the email is a total average of the Availability Rate. I hope this makes sense.
- Clive_WatsonBronze ContributorMaybe?
let weeklyTotalAverage = toscalar(
Heartbeat
| where Computer has ""
| where TimeGenerated > ago(7d)
| summarize heartbeatPerHour = count() by bin_at(TimeGenerated, 1m, ago(1d)), Computer
| extend AvailablePerHour = iff(heartbeatPerHour > 0, true, false)
| summarize TotalAvailableMinutes = countif(AvailablePerHour == true) by Computer
| extend AvailabilityRate = round(TotalAvailableMinutes*100.0/10080, 3)
| project Computer, AvailabilityRate
| summarize weeklyTotalAverage=avg(AvailabilityRate)
);
Heartbeat
| where Computer has ""
| where TimeGenerated > ago(7d)
| summarize heartbeatPerHour = count() by bin_at(TimeGenerated, 1m, ago(1d)), Computer
| extend AvailablePerHour = iff(heartbeatPerHour > 0, true, false)
| summarize TotalAvailableMinutes = countif(AvailablePerHour == true) by Computer
| extend AvailabilityRate = round(TotalAvailableMinutes*100.0/10080, 3)
| project Computer, AvailabilityRate, weeklyTotalAverage=round(weeklyTotalAverage,3)