Before attempting these methods, make sure Flux is enabled by setting
flux-enabled = true in the [http] section of your InfluxDB configuration file.

Chronograf’s Data Explorer

Chronograf v1.7+ supports Flux in its Data Explorer.
Flux queries can be built, executed, and visualized from within the Chronograf user interface.

Influx CLI in “Flux mode”

InfluxDB v1.7+’s influx CLI includes a -type option which allows you specify
what type of interactive session to start.
-type=flux will start an interactive read-eval-print-loop (REPL) that supports Flux.

influx -type=flux

Any Flux query can be executed within the REPL.

Influx CLI via parameter

Flux queries can also be passed to the Flux REPL as a parameter using the influx CLI’s -type=flux option and the -execute parameter.
The accompanying string is executed as a Flux query and results are output in your terminal.

influx -type=flux -execute '<flux query>'

Influx CLI via STDIN

Flux queries an be piped into the influx CLI via STDIN.
Query results are otuput in your terminal.

echo'<flux query>'| influx -type=flux

InfluxDB API

Flux can be used to query InfluxDB through InfluxDB’s /api/v2/query endpoint.
Queried data is returned in annotated CSV format.

In your request, set the following:

accept header to application/csv

content-type header to application/vnd.flux

This allows you to POST the Flux query in plain text and receive the annotated CSV response.