Get started with Flux
Flux is InfluxData’s functional data scripting language designed for querying, analyzing, and acting on data.
This multi-part getting started guide walks through important concepts related to Flux, how to query time series data from InfluxDB using Flux, and introduces Flux syntax and functions.
Flux design principles
The following example illustrates querying data stored from the last five minutes,
filtering by the
cpu measurement and the
cpu=cpu-usage tag, windowing the data in 1 minute intervals,
and calculating the average of each window:
from(bucket:"example-bucket") |> range(start:-1h) |> filter(fn:(r) => r._measurement == "cpu" and r.cpu == "cpu-total" ) |> aggregateWindow(every: 1m, fn: mean)
Flux introduces important new concepts you should understand as you get started.
Flux uses pipe-forward operators (
|>) extensively to chain operations together.
After each function or operation, Flux returns a table or collection of tables containing data.
The pipe-forward operator pipes those tables into the next function or operation where
they are further processed or manipulated.
Flux structures all data in tables. When data is streamed from data sources, Flux formats it as annotated comma-separated values (CSV), representing tables. Functions then manipulate or process them and output new tables.
Every table has a group key which describes the contents of the table. It’s a list of columns for which every row in the table will have the same value. Columns with unique values in each row are not part of the group key.
As functions process and transform data, each modifies the group keys of output tables. Understanding how tables and group keys are modified by functions is key to properly shaping your data for the desired output.
Example group key
[_start, _stop, _field, _measurement, host]
_value are excluded from the example group key because they
are unique to each row.
Tools for working with Flux
The Execute queries guide walks through the different tools available for querying InfluxDB with Flux.
Bug Reports and Feedback
Thank you for being willing to help test InfluxDB v2.0 alpha! Feedback and bug reports are welcome and encouraged both for InfluxDB and this documentation.