Flux reference documentation
All Flux reference material is provided in the Flux documentation:
Flux with the InfluxDB IOx storage engine
When querying data from an InfluxDB bucket powered by InfluxDB IOx, use the following input functions:
iox.from()
: alternative tofrom()
.iox.sql()
: execute a SQL query with Flux.
Both IOx-based input functions return pivoted data with a column for each field in the output. To unpivot the data:
- Group by tag columns.
- Rename the
time
column to_time
. - Use
experimental.unpivot()
to unpivot the data. All columns not in the group key (other than_time
) are treated as fields.
import "experimental"
import "experimental/iox"
iox.from(bucket: "example-bucket", measurement: "example-measurement")
|> range(start: -1d)
|> group(columns: ["tag1", "tag2". "tag3"])
|> rename(columns: {time: "_time_"})
|> experimental.unpivot()
import "experimental"
import "experimental/iox"
query = "SELECT * FROM \"example-measurement\" WHERE time >= now() - INTERVAL '1 day'"
iox.sql(bucket: "example-bucket", query: query)
|> group(columns: ["tag1", "tag2". "tag3"])
|> rename(columns: {time: "_time_"})
|> experimental.unpivot()
Flux performance with InfluxDB IOx
When querying data from an InfluxDB bucket powered by InfluxDB IOx, using iox.from()
is less performant than querying a TSM-powered bucket with from()
.
For better Flux query performance, use iox.sql()
.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.