Query Details
let window = 1d;
let bucket = 1h;
let min_t = toscalar(customMetrics | where timestamp > ago(window) | summarize min(timestamp));
let max_t = toscalar(customMetrics | where timestamp > ago(window) | summarize max(timestamp));
customMetrics
| where timestamp > ago(window)
| make-series totalHeartbeatCountByHour=count() default=0 on timestamp in range(min_t, max_t, bucket)
| mvexpand timestamp to typeof(datetime),
totalHeartbeatCountByHour to typeof(double)
| sort by timestamp desc
This query calculates the total number of heartbeats received per hour for a specific time window. It first defines a window and bucket size, then finds the minimum and maximum timestamps within that window. It then filters the customMetrics data based on the timestamp within the window and creates a series of total heartbeat counts per hour using the specified bucket size. Finally, it expands the timestamp and count columns, sorts the results by timestamp in descending order.

Rod Trent
Released: March 26, 2020
Tables
Keywords
Operators