AZ-104 Monitor and Maintain Azure Resources Practice Question
Exhibit
Workspace: law-prod Table: Heartbeat Sample records -------------- TimeGenerated Computer ResourceId 2026-04-26T10:00:00Z VM01 /subscriptions/111/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/VM01 2026-04-26T10:01:00Z VM01 /subscriptions/111/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/VM01 2026-04-26T10:02:00Z VM02 /subscriptions/111/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/VM02 2026-04-26T10:03:00Z VM02 /subscriptions/111/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/VM02 Requirement ----------- Alert if a VM has no heartbeat for 15 minutes.
Based on the exhibit, the operations team wants an alert that fires when any VM has not sent a heartbeat in the last 15 minutes. Which KQL query should they use as the condition for the log alert?
⚠ Common exam trap
It's easy for candidates to confuse the direction of the time comparison, picking Option A (which fires on VMs that *have* sent a heartbeat recently) instead of Option B (which fires on VMs that have *not* sent a heartbeat recently).
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen < ago(15m)
The query uses `summarize max(TimeGenerated) by Computer` to get the latest heartbeat timestamp per VM, then filters with `where LastSeen < ago(15m)` to identify VMs whose last heartbeat is older than 15 minutes. This directly matches the alert condition: any VM that has not sent a heartbeat in the last 15 minutes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen > ago(15m)
Why it's wrong here
This query groups heartbeats by computer and computes the maximum TimeGenerated for each, but the where clause selects LastSeen values greater than ago(15m), meaning it returns computers that have been heard from within the last 15 minutes. That is precisely the opposite of an outage alert: it flags healthy, responsive VMs and silently omits any VM whose last heartbeat is older than 15 minutes. Consequently, VM01 would not appear when it is down, and the alert condition would never trigger for the intended scenario.
When this WOULD be correct
This query would be correct if the requirement was to alert when a VM has sent a heartbeat within the last 15 minutes (e.g., to confirm active VMs). For example: 'Alert when any VM has sent a heartbeat in the last 15 minutes.'
- ✓
Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen < ago(15m)
Why this is correct
This query summarizes the most recent heartbeat per computer and then filters for systems whose latest record is older than 15 minutes. That matches the requirement to alert when a VM has stopped sending heartbeat data.
- ✗
Heartbeat | where TimeGenerated > ago(15m) | summarize count() by Computer | where count() == 0
Why it's wrong here
The initial where clause limits the dataset to heartbeats generated in the last 15 minutes, then summarize count() by Computer attempts to produce rows per computer. Log Analytics does not emit a row with count() == 0 for computers that have no matching events—absent data simply yields no output rows for those computers, so the condition can never evaluate to true. Even for a VM like VM01 that has stopped sending heartbeats, this query returns an empty result and the alert never fires, making it an ineffective outage-detection pattern.
When this WOULD be correct
This query would be correct if the alert should fire when a VM has sent fewer than a certain number of heartbeats (e.g., less than 2) in the last 15 minutes, and the heartbeat table includes a row for each heartbeat event. For example, 'Heartbeat | where TimeGenerated > ago(15m) | summarize count() by Computer | where count() < 2' would alert on VMs with insufficient heartbeats.
- ✗
Heartbeat | distinct Computer | where Computer == "VM01"
Why it's wrong here
This query simply enumerates every unique computer name in the Heartbeat table and then filters for the literal string "VM01". Because there is no time predicate, it returns a result as long as VM01 has ever sent a heartbeat—even if the most recent one is weeks old. It cannot determine recency or detect that heartbeats have stopped; it only verifies existence in the table, so it fails to alert on a 15-minute silence.
When this WOULD be correct
If the question asked for an alert that fires only when a specific VM (e.g., 'VM01') has not sent a heartbeat, and the alert condition is based on the absence of a result from this query (e.g., using a 'Result count' condition of 0), then this query would be appropriate.
Option-by-option analysis
Why each answer is right or wrong
Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The AZ-104 exam frequently reuses these exact scenarios with slightly different constraints.
✓Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen < ago(15m)Correct answer▾
Why this is correct
This query summarizes the most recent heartbeat per computer and then filters for systems whose latest record is older than 15 minutes. That matches the requirement to alert when a VM has stopped sending heartbeat data.
✗Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen > ago(15m)Wrong answer — click to see why▾
Why this is wrong here
This query fires when the last heartbeat was seen within the last 15 minutes (LastSeen > ago(15m)), which is the opposite of the desired condition. The alert should trigger when no heartbeat has been received for 15 minutes, i.e., LastSeen is older than 15 minutes.
★ When this WOULD be the correct answer
This query would be correct if the requirement was to alert when a VM has sent a heartbeat within the last 15 minutes (e.g., to confirm active VMs). For example: 'Alert when any VM has sent a heartbeat in the last 15 minutes.'
Why candidates choose this
Candidates often confuse the direction of the time comparison, thinking 'greater than ago(15m)' means 'older than 15 minutes' instead of 'more recent than 15 minutes ago'.
✗Heartbeat | where TimeGenerated > ago(15m) | summarize count() by Computer | where count() == 0Wrong answer — click to see why▾
Why this is wrong here
The query filters for heartbeats in the last 15 minutes and then summarizes count by Computer. If a VM has no heartbeats in that window, the count is 0, but the 'where count() == 0' clause will not return any rows because the summarize operator only produces rows for computers that have at least one heartbeat in the time range. Thus, VMs with no heartbeat are never represented in the result.
★ When this WOULD be the correct answer
This query would be correct if the alert should fire when a VM has sent fewer than a certain number of heartbeats (e.g., less than 2) in the last 15 minutes, and the heartbeat table includes a row for each heartbeat event. For example, 'Heartbeat | where TimeGenerated > ago(15m) | summarize count() by Computer | where count() < 2' would alert on VMs with insufficient heartbeats.
Why candidates choose this
Candidates may think that filtering for heartbeats in the last 15 minutes and then checking for zero count will catch VMs with no heartbeats, but they overlook that the summarize operator only returns computers that have data in the filtered set, so computers with zero heartbeats are absent from the result.
✗Heartbeat | distinct Computer | where Computer == "VM01"Wrong answer — click to see why▾
Why this is wrong here
This query returns a list of distinct computer names, filtered to only 'VM01'. It does not check heartbeat timeliness or alert on missing heartbeats for all VMs.
★ When this WOULD be the correct answer
If the question asked for an alert that fires only when a specific VM (e.g., 'VM01') has not sent a heartbeat, and the alert condition is based on the absence of a result from this query (e.g., using a 'Result count' condition of 0), then this query would be appropriate.
Why candidates choose this
Candidates may think that listing distinct computers is a necessary step to identify which VMs are missing, or they may confuse the need to filter by a specific VM with the general requirement to monitor all VMs.
Analysis generated from the official AZ-104blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”
Go deeper
Related to this question
About these practice questions
This AZ-104 question is part of Courseiva's 1,049-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on AZ-104
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. In Log Analytics, you want an alert that fires if VM01 has not sent a Heartbeat record in the last 15 minutes. Which query should be used as the alert condition?
medium- A.Heartbeat | where Computer == "VM01" | summarize LastHeartbeat = max(TimeGenerated) | where LastHeartbeat > ago(15m)
- ✓ B.Heartbeat | where Computer == "VM01" | summarize LastHeartbeat = max(TimeGenerated) | where LastHeartbeat < ago(15m)
- C.Heartbeat | where Computer == "VM01" and TimeGenerated > ago(15m) | summarize count() by Computer
- D.Heartbeat | where Computer == "VM01" | summarize count() by bin(TimeGenerated, 15m)
Why B: The alert must fire when VM01 has *not* sent a Heartbeat in the last 15 minutes. The query uses `max(TimeGenerated)` to find the most recent heartbeat, then filters with `where LastHeartbeat < ago(15m)` to detect records older than 15 minutes. This condition evaluates to true when the last heartbeat is older than the threshold, triggering the alert.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-104 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-104 exam.