I am trying to write a simple aggregation query in Kusto that would show me how many machines are at the moment alive, based on heartbeat.
I can get the alive status with the following query:
Heartbeat
| summarize LastHeartbeat=max(TimeGenerated) by Computer
This yields output similar to:
Computer LastHeartbeat [UTC]
VM1 5/4/2020, 3:23:40.227 PM
VM2 5/4/2020, 2:59:46.780 PM
But then I want to add a column that would be max(TimeGenerated) not by Computer, but in total. I was trying to do aggregation by multiple terms, but apparently this is not possible:
Heartbeat
| summarize LastHeartbeat=max(TimeGenerated) by Computer, Latest=max(TimeGenerated)
| extend isAlive = (LastHeartbeat == Latest)
My question is - how can I use the data to render a pie chart showing alive/dead machines? How can I use this data to render a piechart showing ratio of OFF/ON machines?