An administrator needs to monitor a set of Azure virtual machines that report to a Log Analytics workspace. The administrator must identify virtual machines that have not sent a heartbeat in the last minutes, but were active and sent a heartbeat within the last hours.
Which of the following Kusto Query Language (KQL) queries should the administrator run? (Select two.)
- kql
Heartbeat
| where TimeGenerated > ago(24h)
| summarize LastHeartbeat = max(TimeGenerated) by Computer
| where LastHeartbeat < ago(15m)
Answer - kql
Heartbeat
| summarize LastHeartbeat = max(TimeGenerated) by Computer
| where LastHeartbeat between (ago(24h) .. ago(15m))
Answer - Ckql
Heartbeat
| where TimeGenerated between (ago(24h) .. ago(15m))
| summarize LastHeartbeat = max(TimeGenerated) by Computer - Dkql
Heartbeat
| where TimeGenerated > ago(24h)
| summarize LastHeartbeat = max(TimeGenerated) by Computer
| where LastHeartbeat > ago(15m)
Answer
The two correct queries summarize the maximum TimeGenerated per computer first, and then filter the results to find those where the last heartbeat occurred between hours ago and minutes ago.
The correct queries aggregate the latest heartbeat per computer before applying the inactivity check. The query that filters raw data to the last hours and then keeps computers with a last heartbeat older than minutes successfully isolates offline systems. The query using the between operator on the aggregated last heartbeat achieves the exact same logical result by selecting computers whose latest heartbeat falls within the inactive window of hours to minutes ago.
Step-by-Step Solution
Key Concept
KQL Query Order of Operations and Temporal Aggregations