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