A developer runs the query in the exhibit against an Application Insights resource. The query returns thousands of rows because each distinct timestamp forms its own group. The developer needs daily counts of failed requests for the same rolling seven-day window, with one row for each daily bucket that contains request telemetry.
requests
| where timestamp > ago(7d)
| summarize failedCount = countif(success == false) by timestamp
Which change should the developer make to the query?
Grouping by the raw timestamp column creates one group per unique timestamp. Using bin(timestamp, 1d) instead combines requests into daily buckets and returns one row for each bucket represented in the filtered data. Limiting the row count with take or top, or narrowing the window, does not change how the rows are grouped.
- Not correct: Append
| take 7to the end of the query.takereturns an arbitrary set of rows. Each row still holds the count for a single timestamp, not for a day. - Not correct: Append
| top 7 by failedCount descto the end of the query.topreturns the highest-valued rows. Each row is still grouped by a single timestamp, not by day. - Correct: Replace
by timestampwithby bin(timestamp, 1d).bin(timestamp, 1d)rounds timestamps down to daily boundaries, combining requests into one group per daily bucket represented in the filtered data. - Not correct: Replace
ago(7d)withago(1d)in thewhereclause. This shortens the time window to one day and leaves the grouping unchanged, so it does not produce daily counts for the required window.