Flux not working with InfluxDB 1.8

I’ve been trying to get Flux to connect in Grafana. I had Grafana v6.7.2, InfluxDB 1.7.10 and
grafana-influxdb-flux-datasource v5.4.1.

I couldn’t get it to work, even with ‘telegraf/autogen’ as Default bucket, as suggested in InfluxDB Error: Internal Server Error with flux data source on Grafana
I was getting the error

Data source connected, but has no data. Verify the “bucket” field and make sure the bucket has data.

I tried other existing (I think) buckets, but nothing worked.
In the meantime, I could successfully run in CLI
influx -type=flux -username -password -execute ‘from(bucket:“telegraf”) |> range(start:-5m) |> filter(fn:® => r._measurement == “cpu”)’

Then I thought, maybe there is a fix, let me update the packages. And now I’m running InfluxDB 1.8.0 and the same Flux command now returns

Error: 404 page not found
: 404 Not Found

What would be the simplest command to check connectivity? buckets()?
influx -type=flux -username -password -execute ‘buckets()’

Is there a command to query influxdb for flux enabled?

I think Flux is still enabled in my system after the update. I chose to keep the existing .conf.
$ cat /etc/influxdb/influxdb.conf | grep flux-enabled
flux-enabled = true

Hi!

I had the same issue and I solved it by adding the following parameter to the influx cli : -path-prefix /api/v2/query

Now I can run flux queries through influx cli in InfluxDB 1.8. I hope this helps you,

Regards!

1 Like

Yes, that works:

influx -type=flux -path-prefix /api/v2/query -username <user> -password <pass> -execute 'from(bucket:"telegraf")
    |> range(start:-5m)
    |> filter(fn:(r) => r._measurement == "cpu")'

But oddly, it doesn’t with a much simpler command that doesn’t take any arguments:

influx -type=flux -path-prefix /api/v2/query -username <user> -password <pass> -execute 'buckets()'

Am I doing something wrong?

But in any case, I don’t see how this fix helps me with Grafana. I can’t add ‘-path-prefix /api/v2/query’ to the service file (it doesn’t work, and I also want to access the data the regular way). And I don’t see a way to add it in Grafana’s interface. Or do I need to monkey-patch Grafana’s Flux plugin?

Thanks!