Influx v1 shell scripting with InfluxQL

Hi,

I use self hosted InfluxDB 2.7.3 OSS on Linux with buckets set up for with InfluxQL. Now I would like to execute queries in InfluxQL to this Influx database and tried to use influx v1 shell, but I don’t see how to execute commands from a (bash) script, instead of interactively in the shell.
Could anyone point me to the right direction how to do this?

@miliinflux It doesn’t look like the v2 influx CLI supports one-off InfluxQL queries. It only lets you open the shell and run interactive queries. You’ll probably have to hit the v1 query API directly.

export INFLUX_ORG_ID=...    # your org ID
export INFLUX_TOKEN=...     # your API token
export DATABASE=...         # the database to query
export RETENTION_POLICY=... # the retention policy to query

curl --request get \
  "http://localhost:8086/query?orgID=${INFLUX_ORG_ID}&database=${DATABASE}&retention_policy=${RETENTION_POLICY}" \
  --header "Authorization: Token ${INFLUX_TOKEN}" \
  --header 'Accept: application/csv' \
  --header 'Content-type: application/json' \
  --data-urlencode "q=SELECT * FROM measurement"

HI @scott,
thank you for the fast reply. Since Flux will be no longer supported in the future and the use of InfluxQL is suggested, can we expect a change of this in the future?

Flux is still supported, but it has been put into maintenance mode, meaning it is only receiving security patches. However, Flux as it stands today, is supported in both InfluxDB v1 and v2. For InfluxDB v2, Flux is the primary query language.

While I can’t say for certain that it won’t be added in the future, it won’t happen in the near term. Most of the InfluxDB engineering efforts are focused on v3. We still have a team dedicated to InfluxDB v2 and v2-dependent products and you’re welcome to file a feature request. Just specify that this feature request is for InfluxDB v2.