InfluxDB Error: Bad Gateway

I am running InfluxDB and Grafana in docker contianers, and keep getting the above error message.

##InfluxDB Web Gui settings##
Bucket: home_assistant

##Grafana Web Gui settings##
Data Sources: InfluxDB-1
Name: Home Assistant
url: http://192.168.1.230:8086
Database: home_assistant

I also know the info for the following:
Token: xxx
User ID: xxx
Organization ID: xxx
Bucket ID: xxx

At one point I did get a green light, by following this great post by Ivana Huckova. But, when I tried to add a dashboard the graph had a little red exclamation point in it. And, Since All configuration of 2.x is through the web frontend of influxdb, Not through rest calls, I can’t use the CLI.

Cans someone tell me exactly which details go into which fields?

Well I just changed the Query Language to Flux and I can’t tell if that made things worse or better. Firstly it added 2 data sources. Now I have 2 databases to choose from, both are giving me problems for different reasons.
The first is just the standard red exclmation point.


The second one has no exclamation point, but all the fields are blank

I did noticed when I used QL , that when I added the source and clicked “save and test” it said 3 buckets found.

Next I went back to the data sources, and scroll to the bottom of the configuration, I am still getting InfluxDB Error: Bad Request

One thing I want to point out is I don’t know what specifically is supposed to go in which fields for this setup:

If you’re using InfluxDB 2.x then you need to use the Flux datasource in Grafana, and not InfluxQL. It wasn’t clear from your first post whether that’s what you tried initially?

1 Like

Thanks.

Yes, initially I tried InfluxQL. In my second post, I was going through the process with Flux.

Editied my post to reflect that.

Are there docs that are up to date that I am just not seeing?

This does not look at all like the most current version of Grafana

I think the Grafana docs should be up to date: Flux support in Grafana | Grafana Labs. But yes, the ones you pointed to on the InfluxDB website show an older version of Grafana.

I have one observation and two questions:

  • In one of your screenshots you’ve turned on Basic auth and you have configured a token and you have a custom header. I know you were probably just trying things out, but I think that Basic auth and the custom header should not be necessary. Can you try just setting the token? As a rule of thumb, unless you have a specific reason to set the datasource settings a particular way, it’s fine to leave defaults/blank fields.
  • Can your containers definitely see each other on the network?
  • What’s the actual error you’re getting?
1 Like

First of all thanks so much for sticking around. I’ve really been trying to research what I can in between these posts, to minimize it being nothing other than hand holding, but for you it probably feels just like that.

I did exactly as you said - just setting the token and this - and it said three buckets found! When I hit “back”, I now see 2 data sources; “InfluxDB Default” and “Home Assistant” .

But, when I go to dashboards, there’s that red exclamation point in the upper right corner saying InfluxDB Error: Bad Gateway .

What’s more, I returned to add data source just now, deleted the sources, and tried to re-add them again. This time no new buckets are found, and I get a new error saying Error reading InfluxDB

For your second question; I don’t know if my Grafana and InfluxDB containers can definitely see each other. I know my Home Assistant container and InfluxDB container can see each other as I have data from my Home Assistant server passing into InfluxDB.

For your second question; I don’t know if my Grafana and InfluxDB containers can definitely see each other. I know my Home Assistant container and InfluxDB container can see each other as I have data from my Home Assistant server passing into InfluxDB.

Hi,
if the two containers are both in the same docker non-default bridge network each one should be able to resolve the other’s ip address using the container name. Supposing you have grafana1 and influxdb1 containers in the same bridge network, you can connect to grafana1 bash shell with “docker exec -it grafana1 /bin/bash” and then you can see if it resolves the ip address of grafana1 with the following command:

bash-5.0$ nslookup influxdb1                                                                                                                      
Server:         127.0.0.11                                                                                                                        
Address:        127.0.0.11:53                                                                                                                     
                                                                                                                                                  
Non-authoritative answer:                                                                                                                         
Non-authoritative answer:                                                                                                                         
Name:   influxdb1                                                                                                                                 
Address: 172.18.0.129  

As you can see, my influxdb1 container can resolve the ip of grafana1 on the docker bridge network on which they are connected, which is 172.18.0.129

Then you should remember that if you point influxdb1 from grafana1 you should use as destination port the port on which influxdb1 is listening within its container, not the exposed one, if different, so by default you should point http://influxdb1:8086

1 Like

I think I figured it out, and if I did, then it turns out that it was working fine after I followed the advice here. While I don’t have the old option of adding fields, selecting measurements etc, when I picked a sample query, I saw all my data. If that’s the case, I guess that’s a win.

Am I correct that in this new version I have to type out everything I want?

Yup, that sounds about right. The visual query editor for Flux is still an open issue on Github, so indeed, for the time being you need to compose the raw query.