grafana
grafana copied to clipboard
Connection to InfluxDB 2.1.1 with Flux
Hi,
I'm trying to add InfluxDB using Flux as a datasource to Grafana. Unfortunately, I'm not able to get a connection. It works perfectly with InfluxQL, though. Grafana, InfluxDB and Telegraf is running in Docker containers... all containers are started with docker-compose (link below).
Grafana Version: v8.3.6 (no plugins) InfluxDB Version: 2.1.1 OS: MacOS 12.2 Browsers: Safai/Chrome
Datasource Config: https://github.com/Teuse/rpi-monitoring/blob/main/etc/grafana-provisioning/datasources/datasource.yml Docker-Compose: https://github.com/Teuse/rpi-monitoring/blob/main/docker-compose.yml
I googled quite. I found some suggestions with custom headers... nothing worked:
- Authorization: Token
- token: Token
- token:
How to reproduce it (as minimally and precisely as possible):
- To reproduce, start InfluxDB 2.1.1 and Grafana v8.3.6 with the mentioned datasource config.
- In Grafana go to the datasource Settings and click "Test". -> See "InfluxDB Error: Bad Request"
The logs in InfluxDB and Grafana are:
rpi-monitoring-influxdb-1 | ts=2022-02-13T10:01:29.763989Z lvl=info msg=Unauthorized log_id=0Zdc8CkW000 error="token required"
rpi-monitoring-grafana-1 | t=2022-02-13T10:01:29+0000 lvl=warn msg="Flux query failed" logger=tsdb.influx_flux err="unauthorized: unauthorized access" query=buckets()
rpi-monitoring-grafana-1 | t=2022-02-13T10:01:29+0000 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=teuse method=POST path=/api/ds/query status=400 remote_addr=192.168.144.1 time_ms=62 size=182 referer=http://localhost:3000/datasources/edit/P5697886F9CA74929
I see the same thing. Looking at the wire it seems the Authorization header is missing. Even when adding it manually it is stil missing:
Internet Protocol Version 6, Src: ::1, Dst: ::1
Transmission Control Protocol, Src Port: 36514, Dst Port: 8086, Seq: 1, Ack: 1, Len: 317
Hypertext Transfer Protocol
POST /api/v2/query?org=private HTTP/1.1\r\n
[Expert Info (Chat/Sequence): POST /api/v2/query?org=private HTTP/1.1\r\n]
[POST /api/v2/query?org=private HTTP/1.1\r\n]
[Severity level: Chat]
[Group: Sequence]
Request Method: POST
Request URI: /api/v2/query?org=private
Request URI Path: /api/v2/query
Request URI Query: org=private
Request URI Query Parameter: org=private
Request Version: HTTP/1.1
Host: localhost:8086\r\n
User-Agent: influxdb-client-go/2.6.0 (linux; amd64)\r\n
Content-Length: 122\r\n
[Content length: 122]
Accept-Encoding: gzip\r\n
Content-Type: application/json\r\n
\r\n
[Full request URI: http://localhost:8086/api/v2/query?org=private]
[HTTP request 1/1]
File Data: 122 bytes
JavaScript Object Notation: application/json
This has been solved for me with 8.4.0
This has been solved for me with 8.4.0
Unfortunately, it's still not working for me... same error: msg="Flux query failed" err="unauthorized: unauthorized access" query=buckets().
I used the docker image grafana/grafana-oss:8.4.0.
Could be related to issues we had with propagating headers #43812. Probably something similar is needed for influx.
@Teuse apologies for not getting to this sooner. We're sweeping through unaddressed issues and wondering if you are still encountering this?
Thanks for coming back to this issue. Unfortunately, I don't have time to check if the issue still exists.
I'm gonna try and see if I can reproduce this locally
I'm unable to reproduce any issues connecting flux 2.1.1/latest with Grafana 8.4.0/9.x.
If it is working for you, than I'm might doing something wrong 😑 I was able to look into this issue again... It's still not working. Here is my code: https://github.com/Teuse/blackberry-monitor
- Just checkout the repository
- Add a
.envfile in project root with following content
INFLUXDB_USERNAME="whoever"
INFLUXDB_PASSWORD="password"
INFLUXDB_TOKEN="123456"
INFLUXDB_ORG="org0"
INFLUXDB_BUCKET="bucket0"
- run
docker compose up - Open grafana on localhost:3000 and navigate to settings -> data sources -> InfluxDB_v2_Flux
- Setup InfluxDB Details (it's not automatically setup, don't know why... I need to look into it) Organization: org0 Token: 123456 Defalut Bucket: bucket0
- -> Test
Expected Result The test should be successful
Actual Result
Error unauthorized: unauthorized access error reading buckets
As menthoned above already, I also tried to add some Custom HTTP Headers e.g. Authorization: 123456 without success
I also have this issue. The difference with my install is using the .deb for RaspberryPiOs. Clean installs everywhere.
I also have this issue. The difference with my install is using the .deb for RaspberryPiOs. Clean installs everywhere.
Turns out the "Copy to Clipboard" API key function doesn't work.
Turns out the "Copy to Clipboard" API key function doesn't work.
Do you have a workaround to get this working somehow?
Turns out the "Copy to Clipboard" API key function doesn't work.
Do you have a workaround to get this working somehow?
Crtl + C, Crtl + V.
@Jonesy1080 Which "copy to clipboard" functionality are you talking about, is this something in Grafana?
@Jonesy1080 Which "copy to clipboard" functionality are you talking about, is this something in Grafana?
When setting up a data source in Grafana from InfluxDB2, you need Organization, Token, and Bucket. I wouldn't want to type the Token, so I copy it from InfluxDB2.
In InfluxDB2, you create an API token. Upon creation, it gives you a button, "Copy to Clipboard". I pasted the expected API key into a text editor and it was not the API key.
@Jonesy1080 Thank you... what a stupid problem that I have been stuck on for weeks.
Can't reproduce the issue. Copy to Clipboard works for me. Does the connection Grafana -> InfluxDB2 work for you, when you type the API key?
Can't reproduce the issue. Copy to Clipboard works for me. Does the connection Grafana -> InfluxDB2 work for you, when you type the API key?
It works fine when I use the operating system copy/paste. Working from an iPad if that matters.
Same Problem here. Firefox 110.0.1 on Windows 10. The function "Copy to clipboard" did not copy the API Key to the clipboard, despite the Popup Message on the website. Took me quite a while to figure out.
Are we talking about the copy to clipboard functionality within the influxDB admin?

This one, in InfluxDB, seems to be the problem. It gives a successful toast message but nothing gets copied into the clipboard.

@Jonesy1080 Which "copy to clipboard" functionality are you talking about, is this something in Grafana?
When setting up a data source in Grafana from InfluxDB2, you need Organization, Token, and Bucket. I wouldn't want to type the Token, so I copy it from InfluxDB2.
In InfluxDB2, you create an API token. Upon creation, it gives you a button, "Copy to Clipboard". I pasted the expected API key into a text editor and it was not the API key.
at today still have the same issue
This one, in InfluxDB, seems to be the problem. It gives a successful toast message but nothing gets copied into the clipboard.
confirmed, I have got the same bad behavior and still not working as today.
Thanks @AlanCodega, this appears to be an issue with influx, and not Grafana. I found a related issue on their github: https://github.com/influxdata/influxdb/issues/24051, please feel free to reach out there.