Why is this Alert not working as expected

Mark Pearson 100 Reputation points
2025-10-16T13:18:24.5366667+00:00

I have the following Alert set up in Azure Monitor. It's purpose is to alert us if an automated shutdown does not run correctly and therefore our Azure VM is running for longer than 3 hours, but for some reason it is not firing at all:

User's image

User's image

NOTE: I have redected the server name, so the dimension value would be the actual server name if this where not changed.

If I run the KQL manually I get the following result:

User's image

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
{count} votes

1 answer

Sort by: Most helpful
  1. Siva shunmugam Nadessin 1,990 Reputation points Microsoft External Staff Moderator
    2025-10-16T18:21:16.66+00:00

    Hello Mark Pearson,

    Your query returns one static value (1440), so there’s nothing to aggregate per time slice hence it is not firing for the selected Measure = UptimeMinutes, Aggregation type = Total, and Granularity = 15 minutes.

    Azure Monitor expects time-series data for aggregation, but your query returns a single static row (no timestamp column for grouping). So the alert engine never evaluates the condition properly.

    How to Fix

    Change to following

    Measurement : Table rows

    Aggregation Type: Empty

    Aggregation granularity: You can keep default to 15 minutes.

    Operator: Greater than

    Threshold: 0

    User's image

    User's image

    Split by dimensions: Leave blank (or remove Computer split since query already filters).

    User's image

    The reason behind the logic is

    The query already filters for UptimeMinutes > 180.

    If any row exists, the alert fires.

    No dependency on time-series aggregation or granularity.

    Updated KQL query, it's the same query you have used, the only change is update in threshold variable.

    let threshold = 180; // 3 hours in minutes
    Heartbeat
    | where Computer == "<your-server-name>"
    | summarize FirstSeen = min(TimeGenerated) by Computer
    | extend UptimeMinutes = datetime_diff('minute', now(), FirstSeen)
    | where UptimeMinutes > threshold
    

    Try and let us know if any queries?

    [Edited with screenshots]

    Thanks.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.