Question 583 of 1,170
Monitor and Maintain Azure ResourcesmediumMultiple ChoiceObjective-mapped

KQL Query for Log Alert on Missing Heartbeat from Any VM

This AZ-104 practice question tests your understanding of monitor and maintain azure resources. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

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?

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.

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)

Option B is correct because 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.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

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 finds machines that have been seen recently, which is the opposite of the requested outage condition.

    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.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Heartbeat | where TimeGenerated > ago(15m) | summarize count() by Computer | where count() == 0

    Why it's wrong here

    Filtering to the last 15 minutes first removes older data, so the count cannot prove absence of records for a VM in the needed way.

    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 only lists a computer name if it appears in the table. It does not detect that the last heartbeat was older than 15 minutes.

    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?”

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates often 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).

Detailed technical explanation

How to think about this question

The `Heartbeat` table in Azure Monitor collects agent heartbeats every 5 minutes by default for Azure VMs with the Log Analytics agent. Using `max(TimeGenerated)` per computer gives the most recent heartbeat, and comparing it to `ago(15m)` (a KQL time literal) effectively checks for a gap of three missed heartbeat intervals. This pattern is commonly used for 'heartbeat failure' alerts and must account for time zone normalization (all timestamps are UTC).

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

An e-commerce site experiences heavy traffic on Black Friday and near-zero traffic during off-peak weeks. Rather than provisioning permanent large VMs, the team uses auto-scaling groups that add capacity automatically under load and reduce it overnight. Questions like this test whether you understand elasticity, availability zones, and cloud compute scaling patterns.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related AZ-104 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free AZ-104 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this AZ-104 question test?

Monitor and Maintain Azure Resources — This question tests Monitor and Maintain Azure Resources — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Heartbeat | summarize LastSeen=max(TimeGenerated) by Computer | where LastSeen < ago(15m) — Option B is correct because 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.

What should I do if I get this AZ-104 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more ways 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: Option B is correct because 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.

Keep practising

More AZ-104 practice questions

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.