1. Windowed aggregate
aggregateWindow groups rows into fixed time buckets and reduces each with an aggregate function.
aggregateWindow(every: 5m, fn: mean)Typorithm · medium
Step 1 of 8 · intro card
Flux
aggregateWindow groups rows into fixed time windows (every: 5m) and reduces each with an aggregate (fn: mean) — that is downsampling over time. yield names and emits the result.
Raw time-series data is dense; aggregateWindow downsamples it by grouping rows into fixed windows and collapsing each window to a single value.
every: 5m sets the window width and fn: mean is the reducer, so each 5-minute slice becomes its average; swap fn for sum, max, min, or count as needed.
yield(name: "mean") labels and emits the table as a named result; without a yield, the pipeline still implicitly outputs, but yield lets you name and emit multiple results.
aggregateWindow buckets rows by time and reduces each.
every sets the window; fn sets the aggregate.
yield names and emits the result.
from(bucket: "metrics")
|> range(start: -1h)
|> aggregateWindow(every: 5m, fn: mean)
|> yield(name: "mean")Connect each part of the code to the concept before you type.
aggregateWindow groups rows into fixed time buckets and reduces each with an aggregate function.
aggregateWindow(every: 5m, fn: mean)every: 5m sets the window width, producing one output point per 5-minute interval — that is downsampling.
every: 5mfn: mean reduces each window to its average; you could use sum, max, count, and so on.
fn: meanyield names and emits a result table so it appears in the query output.
yield(name: "mean")Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.