Grafana and InfluxDB - How to configure a Query without Flux

Hey guys,

sorry for this question, but I don’t know how to get this done.
I have a complete new installation of Grafana 8.2.1 and InfluxDB 2.0.9.
In my old installation of Grafana (6.4.2) , I had the possibility to select the measurements via a dropdown
image

In my new installation I only have the possibility to use ‘flux code’ or I don’t know how to switch to the old interface.
image

Can someone help?

Hello,
the easyest way with influxdb >2 is to create the Dashboards direct in the influx webui and copy it to to Grafana.

Using FLUX has many advantages however you can of course query InfluxDB 2+ with InfluxQL (using InfluxDB 1.x compatibility API and Grafana 7.1+). There are many ways. In my opinion the easiest way is as follows:

With InfluxDB CLI:

Use the influx v1 auth create command to grant read/write permissions to specific bucket (ex. openhab_db),

influx v1 auth create \
  --read-bucket 00xX00o0X001 \
  --write-bucket 00xX00o0X001 \
  --username example-user

and write new password when prompted, 00xX00o0X001 is your bucket IDs to grant read or write permissions to (ex. openhab_db).

Then use the influx v1 dbrp create command to create a DBRP mapping.

When using InfluxQL to query InfluxDB 2+, the query must specify a database and a retention policy. InfluxDB DBRP mappings associate database and retention policy combinations with InfluxDB 2.0 buckets.

influx v1 dbrp create \
  --db example-db \
  --rp example-rp \
  --bucket-id 00xX00o0X001 \
  --default

where:
example-db - database name used in Grafana connection settings) ex. openhab_db/autogen,
example-rp - retention policy name (not retention period) ex. autogen,
Now you are ready to configure your InfluxDB 2 connection in Grafana.

In Grafana:

With InfluxQL selected as the query language in your InfluxDB data source settings do the following:
Database: Enter the database name mapped to your InfluxDB 2.0 bucket,
User: Enter the username associated with your InfluxDB 1.x compatibility authorization,
Password: Enter the password associated with your InfluxDB 1.x compatibility authorization,
HTTP Method: Select GET.

Reference:
https://docs.influxdata.com/influxdb/v2.0/tools/grafana/?t=InfluxQL

You can configure the query language in your data source in Grafana. I have one for “InfluxQL” and one for “Flux”. If you select “InfluxQL” you should get your dropdowns.

@Dave_K it is true when you are using InfluxDB 1.7.x or 1.8.x. When you query InfluxDB 2.x with InfluxQL you have to use InfluxDB 1.x compatibility endpoints that work with InfluxDB 1.x client libraries and third-party integrations like Grafana and others. As I said before the InfluxQL query must specify a database and a retention policy which is not used in InfluxDB 2 bucket. InfluxDB DBRP mappings associate database and retention policy combinations with InfluxDB 2.0 buckets instead.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.