Grafana v8.3.3 Setting up InfluxQL (InfluxDB 2.0.3) data source (again)

Hello.
After hours of trial and no success I humbly turn to the experts.
Just after Influx v2 came out some 2 years back, I decided to upgrade, and that broke all my Grafana panels because of the Flux QL becoming default.
(When I originally installed Grafana v4 something and InfluxDB v1.8 everything worked just bang out of the box.)
I am just now re-visiting Grafana because I miss my graphs, but am struggling.

My setup:
I’m using InfluxDB v2.0.3 as persistence storage for my openHab3 setup.
Everything woks fine, and OH3 is set up to use V2 as ‘database version’ (=Flux QL I imagine.)

image denied by forum

OH3 can Analyse single items and that works fine:
image denied by forum

But what fun are single graphs, right?

So enter Grafana v8.3.3, which I want to set up using InfluxQL (v1).
I have tried both the Header Auth method with API token and user/pw with authenticated user, both with the same result:

omr@shs2:~$ influx bucket list
ID                      Name                    Retention       Organization ID
b6a3ceaa4633dd60        _monitoring             168h0m0s        427da286ec49d684
0919e1fd771206a7        _tasks                  72h0m0s         427da286ec49d684
69d6af7550af3294        openhab_db/autogen      0s              427da286ec49d684

omr@shs2:~$ influx v1 dbrp list
ID                      Database        Bucket ID               Retention Policy        Default Organization ID
08c3b4d754a05000        openhab-db      69d6af7550af3294        Forever                 true    427da286ec49d684
08c3b5c681605000        openhab_db      69d6af7550af3294        Forever                 true    427da286ec49d684
08c3bb7cc5b43000        openhab         69d6af7550af3294        Forever                 true    427da286ec49d684
omr@shs2:~$ influx v1 auth list
ID                      Description     Name / Token    User Name       User ID                 Permissions
08c4002beef43000                        openhab         openhab         06f1f3ef50380000        [write:orgs/427da286ec49d684/buckets/69d6af7550af3294]

My latest attempt is using the v1 auth name openhab:
image denied by forum, but it shows that Data source is working

Everything looks fine, but when I Explore, no Measurements are listed:

If I manually enter a known existing measurement and tries the Inspector I get this:

Any pointers as to what to try next are most welcome.

Edit:
Running the query, nothing shows up in sudo tail -F /var/log/grafana/grafana.log so I guess Grafana is happy.

sudo journalctl -u influxdb.service shows:

Jan 16 14:46:57 shs2 influxd[1158]: ts=2022-01-16T13:46:57.259994Z lvl=info msg="executing new query" log_id=0Z3jR4MW000 query="SHOW MEASUREMENTS LIMIT 100"
Jan 16 14:46:57 shs2 influxd[1158]: ts=2022-01-16T13:46:57.260086Z lvl=info msg="Executing query" log_id=0Z3jR4MW000 service=query query="SHOW MEASUREMENTS ON openhab LIMIT 100"
Jan 16 14:46:58 shs2 influxd[1158]: ts=2022-01-16T13:46:58.727749Z lvl=info msg="executing new query" log_id=0Z3jR4MW000 query="SHOW MEASUREMENTS WITH MEASUREMENT =~ /(?i)BathTemperature/ LIMIT 100"
Jan 16 14:46:58 shs2 influxd[1158]: ts=2022-01-16T13:46:58.727875Z lvl=info msg="Executing query" log_id=0Z3jR4MW000 service=query query="SHOW MEASUREMENTS ON openhab WITH MEASUREMENT =~ /(?i)BathTemperature/ WHERE _name =~ /(?i)BathTemperature/ LIMIT 100"
Jan 16 14:47:00 shs2 influxd[1158]: ts=2022-01-16T13:47:00.079622Z lvl=info msg="executing new query" log_id=0Z3jR4MW000 query="SELECT mean(\"value\") FROM \"BathTemperature\" WHERE time >= now() - 1h and time <= now() GROUP BY time(2s) fill(null)"
Jan 16 14:47:00 shs2 influxd[1158]: ts=2022-01-16T13:47:00.079904Z lvl=info msg="Executing query" log_id=0Z3jR4MW000 service=query query="SELECT mean(value) FROM openhab.Forever.BathTemperature WHERE time >= now() - 1h AND time <= now() GROUP BY time(2s)"
Jan 16 14:47:01 shs2 influxd[1158]: ts=2022-01-16T13:47:01.759300Z lvl=info msg="executing new query" log_id=0Z3jR4MW000 query="SELECT mean(\"value\") FROM \"BathTemperature\" WHERE time >= now() - 1h and time <= now() GROUP BY time(2s) fill(null)"
Jan 16 14:47:01 shs2 influxd[1158]: ts=2022-01-16T13:47:01.759612Z lvl=info msg="Executing query" log_id=0Z3jR4MW000 service=query query="SELECT mean(value) FROM openhab.Forever.BathTemperature WHERE time >= now() - 1h AND time <= now() GROUP BY time(2s)"
Jan 16 14:47:07 shs2 influxd[1158]: ts=2022-01-16T13:47:07.063696Z lvl=info msg="executing new query" log_id=0Z3jR4MW000 query="SELECT mean(\"value\") FROM \"BathTemperature\" WHERE time >= now() - 1h and time <= now() GROUP BY time(2s) fill(null)"
Jan 16 14:47:07 shs2 influxd[1158]: ts=2022-01-16T13:47:07.063956Z lvl=info msg="Executing query" log_id=0Z3jR4MW000 service=query query="SELECT mean(value) FROM openhab.Forever.BathTemperature WHERE time >= now() - 1h AND time <= now() GROUP BY time(2s)"
l

LIMIT 100
I have way more than 100 measurements. Could that be the problem?

Edit2:
Starting to think this a Influx problem since:

omr@shs2:~$ curl --get http://localhost:8086/query?db=openhab_db --header "Authorization: Token c5heYDTRfynpj3UkQleV4s9N3b6LDRVdcTKMRoJyH1J0oLom3qZQivjOnwPsIcjjMqX7XX9td3x-rE674s-CBw=="   --data-urlencode "q=SELECT used_percent FROM openhab_db.Forever.BathTemperature WHERE host=host1"
{"results":[{"statement_id":0}]}
omr@shs2:~$

Asked on their forum as well:

1 Like

Hello. So as you have probably found, the documentation of setting up Grafana with Influx is often outdated and/or unclear because it references old versions of both products and the Flux vs InfluxQL thing is still not crystal clear in the various tutorials and examples online. My understanding is that when one makes the jump from InfluxDB 1.8 to 2.x, then one MUST use Flux, but apparently this thread indicates that InfluxQL can work.

I do not see any obvious problems with what you showed.

Can you see/start Influx Data Explorer at http://localhost:8086 ? It would look like this and you can easily build queries using the choices at the bottom. This makes Flux almost a non-issue because you can build the query using a GUI and then show the Flux query (that you just built) and copy/paste it into Grafana.

Sorry for the long overdue response!
Thank you for pointing me in the right direction.
After selecting the right Organization in Data Explorer, the .measurements column appeared :slight_smile:
I was able to find the Flux query after hitting the Query Builder button.

As for Grafana, v8.3.3 was not able to connect to the influxDb at all. Updating to 9.1.4 fixed that and now it is working with Flux queries. Selecting InfluxQl it is not able to connect, so all my old Dashboards are gone.

@olemr Thanks for the update. Re-creating your dashboards using Flux queries is not that bad. You can build the query using a http://influxdatabase:8086 query builder, then copy/paste it into Grafana.

I’m using InfluxQL and Flux on Grafana 9.x. I set up two Influx data sources pointing to the same Influx database - one for QL, one for flux.

Tricks to using QL:

  1. do not use Password authentication.
  2. add a custom header “Authorization”, with value “Token YOUR_TOKEN_VALUE”. “Token” is case-sensitive.
  3. Check which database / retention policy to use at the command prompt:
    influx v1 dbrp list . I didn’t have to create one, but it’s possible to do so.

I suspect that’d work in Grafana 8.3, but don’t have a test rig handy.

See here for details:

3 Likes

Just found this info on influxdb site

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

1 Like