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.
Setting up the TICK stack with Flux is pretty simple. If you're using the InfluxData Sandbox, it's even simpler. For instructions on using Flux with the Sandbox, skip down.
Download the nightly builds Chronograf, and InfluxDB to get the most recent versions that include Flux and Flux-dependent
functionality.
Nightly builds for each are available on the InfluxData Downloads page.
Once downloaded and unpackaged, move the binaries into your system's $PATH
.
InfluxDB stores its data within a Time-Structured Merge Tree (TSM) format. However, there are two potential indicies
with the underlying TSM file format. The default index-version
is inmem
or in-memory. Upon startup, the TSM files are
read and the in-memory index is rebuilt.
There second option is to use the Time Series Index (TSI) engine, which stores indexed data on disk.
If you are starting from scracth, update your the index-version
setting under the [data]
section in your
influxdb.conf
to use tsi1
:
# ...
[data]
# ...
index-version = "tsi1"
# ...
If you already have been running InfluxDB and have data that you wish to maintain and use, you need to convert your existing TSM-based shards to TSI-supported shards.
Use influx_inspect buildtsi
for converting your TSM-based shards to TSI-based shards. You can read more about using building TSI here.
InfluxDB and Chronograf are all run as separate daemonized processes and must be started separately. Run each of the following commands in their own terminal sessions.
# Start the influxd daemon
influxd -config path/to/influxdb.conf
# Start Chronograf
chronograf
Open Chronograf in your browser of choice at localhost:8888.
Select the wrench icon in the left-hand navigation bar which is the Configuration option. The following screen should appear:
If not already connected to InfluxDB, you will be prompted for connection details. Provide the necessary credentials and save.
To connect Chronograf to the Flux engine within the InfluxDB OSS instance, click on the Flux Editor icon in the left navigation.
Ensure the URL of the InfluxDB OSS instance is used -- and append that with the /v2
suffix.
For example, if you are running InfluxDB on your local machine and using http://localhost:8086
to interact with InfluxDB,
the Flux URL should be: http://influxdb:8086/v2
.
Once the connection is established, the Flux Editor is available from the Data Explorer and when defining cells within a Dashboard. Keep in mind that BOTH InfluxQL and Flux can be used within InfluxDB 1.7.
To use Flux with the InfluxData Sandbox,
start the Sandbox with the -nightly
flag to pull the nightly builds of InfluxDB and
Chronograf.
./sandbox up -nightly
The Flux Editor makes working with Flux a visual process. It consists of 3 panes:
- The Script Editor Where the actual Flux code is written and displayed.
- The Flux Builder A visual representation of your Flux script used to visualize and build your script.
- The Schema Explorer Allows you to explore the actual structure of your data as you're building Flux scripts.
Each pane can be minimized, maximized, or closed depending on how you want to work.
Flux queries are written in the "Script" pane of the Flux Editor. You can also use the Flux Builder to visually build out queries. As queries are updated in the Flex Builder, the are updated in the script editor.
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.
The "Build" pane is a visual representation of your Flux script that used to both visualize and build your script.
As queries are updated in the Flex Builder, the are updated in the script editor.
At any point in your Flux query, you can use the yield()
function to visualize the current state of your query.
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
Basic Syntax
section in the Flux project README
.
You can also explore a walkthrough of the language including a handful of simple expressions and what they mean.