1. Source bucket
from picks the data source: a bucket is InfluxDB's named container of time-series data.
from(bucket: "metrics")Typorithm · easy
Step 1 of 8 · intro card
Flux
A Flux query is a pipeline: from picks a bucket, |> pipes each result into the next function, range limits the time window, and filter keeps only matching rows.
Flux is functional and pipe-forward: every query starts at a source and flows through transformations connected by the |> operator.
from(bucket: "metrics") names the bucket to read; range(start: -1h) restricts the result to the last hour so you never scan the whole bucket.
filter(fn: (r) => ...) runs a predicate against each row r, keeping only rows where the expression is true — here, the cpu measurement on host a.
from selects the source bucket.
|> pipes output into the next function.
range bounds the time window; filter keeps matching rows.
from(bucket: "metrics")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "cpu" and r.host == "a")Connect each part of the code to the concept before you type.
from picks the data source: a bucket is InfluxDB's named container of time-series data.
from(bucket: "metrics")The |> operator sends the output of one function as the input of the next, building a left-to-right pipeline.
|> range(start: -1h)range narrows the data to a time window; start: -1h means the last hour relative to now.
range(start: -1h)filter keeps only rows where the predicate fn returns true, testing each row r's columns.
filter(fn: (r) => r._measurement == "cpu" and r.host == "a")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.