Grafana add-on broken - query to InfluxDB escaping double quotes twice?

The Grafana add-on on my Home Assistant has suddenly broken:

As the screenshot shows, the error is: “InfluxDB Error: error parsing query: found %, expected identifier, string, number, bool at line 1, char 13”

Having a look at the Grafana add-on logs, we have, e.g.

[06/Oct/2020:17:42:28 +0100] 400 192.168.1.108, 172.30.32.1(172.30.32.2) GET /api/datasources/proxy/1/query?db=homeassistant&q=SELECT+mean(%2522value%2522)+FROM+%2522%25C2%25B5g/m%25C2%25B3%2522+WHERE+(%2522entity_id%2522+%253D+'luftdaten_50321_p2')+AND+time+%253E%253D+now()+-+6h+GROUP+BY+time(30s)+fill(linear)%253BSELECT+mean(%2522value%2522)+FROM+%2522%25C2%25B5g/m%25C2%25B3%2522+WHERE+(%2522entity_id%2522+%253D+'luftdaten_50321_p1')+AND+time+%253E%253D+now()+-+6h+GROUP+BY+time(5m)+fill(linear)&epoch=ms HTTP/1.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36)
t=2020-10-06T17:42:28+0100 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/api/datasources/proxy/1/query status=400 remote_addr="192.168.1.108, 172.30.32.1" time_ms=7 size=103 referer="http://homeassistant:8123/api/hassio_ingress/O8QAbIJPrQQi_yQvU33oXkPgHCUuyFgSRBek7B5Qyo0/d/-9IdvviRk/environment?orgId=1"

note the "%2522"s in the URL - which looks as though it’s trying to escape double quotes twice - which correlates with a “%” at char 13 in the SELECT query.

Bizarrely, Grafana has been fine for months now, and has only just started doing this since I tried logging on just after 5 this evening.

So I’m wondering what’s changed to cause this? I’ve tried restarting HassOS but that did not make any difference.

1 Like

BTW, I fixed this by going to the “Configuration - Data Sources” section in Grafana, and changing the connection settings to InfluxDB to use POST instead of GET.

14 Likes

Hi all. I just had the same issue and solved in a similar way. I entered the Grafana - Datasource configuration but I had to change the parameter “http method” to “POST”

15 Likes

Tnx! This worked for me as well!

Just had exactly the same issue. Googled the error and found this thread.

I had a look at my influxdb Datasource in Grafana, lo and behold my “HTTP method” was blank. I changed it to POST and it fixed the issue.

I don’t remember if this was always blank or not, but I had not updated or changed any configuration recently, but it just broke some point today.

3 Likes

I did the suggested “HTTP method” change and now all my graphs are filled with test data or something. it’s not the numbers I saw last night.

When I edit the graph I see this :cry:

query

I’m getting the error while adding the InfluxDB datasource in Graphana

Influxdb plugin: 3.7.6
Grafana: 5.3.0

LE: this fixed the issue for me

Setting HTTP to POST solved it.
Since is a breaking issue it should be mentioned from now on in the documentation or changelog/upgrade instructions.

4 Likes

Ah brilliant - that’ll have done it then! Yes - POST will have meant that the query string problem gets sorted.

Same problem here. Setting HTTP to POST solved it.

Same problem here. Setting HTTP to POST fixed. Thanks @ruthdonna

Thank you thank you thank you all for posting this.

Wonderful, this works, no data lost! Thanks

This was caused by an update of the supervisor, not home assistant. The update will occur automatically, so you rarely see the change notes. Also this was an unintended issue, so not a breaking change.

Version 247 of Supervisor was just released, it should fix the problem. It fixed a similar problem for me with broken URLs (bad percent-encoding) for Grafana and Prometheus (it was also was possible to work around by switching to POST, but now it works with GET).

Same issue and same solution for me! Thank you.

In my case upgrade HA to 0.116 yesterday solved the problem.