Flux is InfluxData's new data language designed for querying, analyzing, and acting on data stored in InfluxDB. Its takes the power of InfluxQL and the TICKscript and combines them into a single, unified data scripting language.
Starting with the 1.7 releases of Chronograf and InfluxDB, Flux is now completely integrated within the InfluxData Sandbox.
There will be ongoing updates and refinements made to the language and the implementation. So, you can always grab the
latest by starting the Sandbox with the -nightly
flag to pull the nightly builds of InfluxDB and
Chronograf.
./sandbox up -nightly
Integrated within the InfluxCLI is a Flux Read-Eval-Print-Loop (REPL) Command Line Interface.
To access the Flux REPL:
// Enter the docker container containing the InfluxCLI from the command prompt
$ ./sandbox enter influxdb
// Once inside the container, start the InfluxCLI tool using the -type flux option
# influx -type flux
//The following should appear
Connected to http://localhost:8086 version 1.7.0
InfluxDB shell version: 1.7.0
Enter a Flux query
>
Remember to use CTL+D to exit the Flux REPL.
The Flux Editor makes working with Flux a visual process. It consists of 3 panes:
- Schema Explorer Allows you to explore the actual structure of your data as you're building Flux scripts.
- Script Editor Where the actual Flux code is written and displayed.
- Function Explorer An online quick reference for many Flux functions.
Each pane can be minimized, maximized, or closed depending on how you want to work.
The "Explore" pane of the Flux Editor allows you to visual explore the structure of your data. This is incredibly helpful as you're building out Flux queries.
Flux queries are written in the "Script" pane of the Flux Editor.
You can use the "explorer" tools around the Script Editor to help you rapidly build out queries. There is also a Script Wizard as part of the Script Editor which allows you to quickly build out the first few lines of your Flux Script.
After you've written your query you can hit the "Run Script" button in the Script Editor to execute the query.
You may want to toggle the "View Raw Data" button above the query visualization panel to switch between your selected visualization and the data returned by the query you've constructed. The default visualization type is a line graph. But, you can select the "Visualization" at the top middle of the screen to alter how the query results are displayed.
The Function Explorer lists the various Flux Functions and in-line documentation describing the function's description, arguments, and an example for how to use it. Scroll through the functions to explore the power of Flux.
Flux draws inspiration from programming languages such as Lisp, Elixir, Elm, Javascript and others, but is specifically designed for analyzing and acting on data. For an introduction into the Flux syntax, view the Flux Getting Started section of the documentation.
Flux Documentation
Flux Specification
Flux Introduction Slides