Query the Flux version

InfluxDB 2.7 includes specific version of Flux that may or may not support documented Flux functionality. It’s important to know what version of Flux you’re currently using and what functions are supported in that specific version.

To query the version of Flux installed with InfluxDB, use array.from() to create an ad hoc stream of tables and runtime.version() to populate a column with the Flux version.

Because the InfluxDB /api/v2/query endpoint can only return a stream of tables and not single scalar values, you must use array.from() to create a stream of tables.

Run the following query in the InfluxDB user interface, with the influx CLI, or InfluxDB API:

  1. import "array"
  2. import "runtime"
  3. array.from(rows: [{version: runtime.version()}])

InfluxDB UI influx CLI InfluxDB API

To return the version of Flux installed with InfluxDB using the InfluxDB UI:

  1. Click Data Explorer in the left navigation bar.

Data Explorer

  1. Click Script Editor to manually create and edit a Flux query.

  2. Enable the View Raw Data toggle or select one of the following visualization types:

  3. Enter and run the following query:

    1. import "array"
    2. import "runtime"
    3. array.from(rows: [{version: runtime.version()}])

To return the version of Flux installed with InfluxDB using the influx CLI, use the influx query command. Provide the following:

  • InfluxDB host, organization, and API token
    (the example below assumes that a CLI configuration is set up and active)
  • Query to execute
  1. $ influx query \
  2. 'import "array"
  3. import "runtime"
  4. array.from(rows: [{version: runtime.version()}])'
  5. # Output
  6. Result: _result
  7. Table: keys: []
  8. version:string
  9. ----------------------
  10. v0.161.0

To return the version of Flux installed with InfluxDB using the InfluxDB API, use the /api/v2/query endpoint.

  1. POST http://localhost:8086/api/v2/query

Provide the following:

  • InfluxDB host
  • InfluxDB organization name or ID as a query parameter
  • Authorization header with the Token scheme and your API token
  • Accept: application/csv header
  • Content-type: application/vnd.flux header
  • Query to execute as the request body
  1. curl --request POST \
  2. http://localhost:8086/api/v2/query?orgID=INFLUX_ORG_ID \
  3. --header 'Authorization: Token INFLUX_TOKEN' \
  4. --header 'Accept: application/csv' \
  5. --header 'Content-type: application/vnd.flux' \
  6. --data 'import "array"
  7. import "runtime"
  8. array.from(rows: [{version: runtime.version()}])'
  9. # Output
  10. ,result,table,version
  11. ,_result,0,v0.161.0

Flux version in the Flux REPL

When you run runtime.version() in the Flux REPL, the function returns the version of Flux the REPL was built with, not the version of Flux installed in the instance of InfluxDB you’re querying.

query