hassio-addons / addon-grafana

Grafana - Home Assistant Community Add-ons
https://addons.community
MIT License
220 stars 61 forks source link

Grafana over nginx not working on FireFox with latest update #255

Closed TheDK closed 2 years ago

TheDK commented 2 years ago

Problem/Motivation

When updating the add-on to the newest version of Grafana, this problem occurs: https://community.grafana.com/t/origin-not-allowed-messages-after-upgrade-to-8-3-6/60550 https://community.grafana.com/t/after-update-to-8-3-5-origin-not-allowed-behind-proxy/60598/2 https://github.com/grafana/grafana/issues/45261

Expected behavior

Grafana working through nginx as part of the HA OS setup.

Actual behavior

Dashboards not working, GUI not working, lots of errors...

Steps to reproduce

Just update and try to create / move / delete a dashboard.

Proposed changes

Implement the fix mentioned in the issues linked above in the add-on.

(My last issue was deleted without comment - anything I am missing with regard to etiquette?)

frenck commented 2 years ago

It is already implemented?

https://github.com/hassio-addons/addon-grafana/blob/main/grafana/rootfs/etc/nginx/includes/proxy_params.conf#L10

Anyways, I don't have this issue myself šŸ¤· Although your issue description is kinda generic, so maybe be more specific.

frenck commented 2 years ago

(My last issue was deleted without comment - anything I am missing with regard to etiquette?)

Issues don't get deleted. They can be closed, however, the bot warns for that. A response will prevent that (as written in the message). Not responding = closed stale / no longer valid. You didn't respond to the bot in that case.

TheDK commented 2 years ago

It is already implemented?

https://github.com/hassio-addons/addon-grafana/blob/main/grafana/rootfs/etc/nginx/includes/proxy_params.conf#L10

Anyways, I don't have this issue myself šŸ¤· Although your issue description is kinda generic, so maybe be more specific.

Sure - here is the environment:

HA: core-2022.3.5 Home Assistant OS 7.5 Grafana Current version: 7.5.0

System Health

version core-2022.3.5
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.103
arch x86_64
timezone Europe/Berlin
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4902 Installed Version | 1.22.0 Stage | running Available Repositories | 1007 Downloaded Repositories | 3
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 7.5 -- | -- update_channel | stable supervisor_version | supervisor-2022.03.5 docker_version | 20.10.9 disk_total | 30.8 GB disk_used | 5.4 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | File editor (5.3.3), Terminal & SSH (9.3.0), Log Viewer (0.12.2), ESPHome (2022.1.2), PostgreSQL (1.0.0), Grafana (7.5.0), TeslaMate (0.17.2)
Lovelace dashboards | 2 -- | -- resources | 1 views | 2 mode | storage

If I directly connect to Grafana it looks like this: (http://192.168.23.15:80/api/hassio_ingress/57ASMUVXUTGabMn4GzqIdrCXvpk3fG7-2P6-wDuHKxk/d/kOuP_Fggz/overview?orgId=1&refresh=30s) grafik

If I open it through HA (http://192.168.23.15:8123/hassio/ingress/a0d7b954_grafana): grafik

One more: grafik

Any idea what the problem might be?

Edit: If I roll back to 7.4.1 ist works fine both ways.

TheDK commented 2 years ago

(My last issue was deleted without comment - anything I am missing with regard to etiquette?)

Issues don't get deleted. They can be closed, however, the bot warns for that. A response will prevent that (as written in the message). Not responding = closed stale / no longer valid. You didn't respond to the bot in that case.

Alright - maybe I really just forgot to post the issue and closed the window prematurely. I was certain I got it logged and it was gone 2 hours later without any comment or trace, but might be user error on my side. Nevermind.

MomosX commented 2 years ago

Hi.

I have the same issue, just noticed it today. No idea if it is related to Grafana or InfluxDB or both :( But it used to work. image

TheDK commented 2 years ago

It has nothing to do with the data source as far as I can tell (I have the problem with a Postgres DB), but not with every dashboard. Also, the errors occur if I try to do something in Grafana (say: move a dashboard to a folder). Problem is I donā€™t see any pattern to the problem so far - just that itā€™s definitely connected to the Grafana updateā€¦

TheDK commented 2 years ago

I have tested some more and have found out, that for me the problem only occurs on Win10 with FireFox 98.01 - it does not occur on Chrome and Edge, also not Safari on iOS, also not on FireFox on MacOS.

The combination Win10 / FireFox also does work with version 7.4.1 of the addon. It also does work in all combinations when accessing Grafana directly and not as a "frame" in Home Assistant.

It appears that something changend in Grafana that FireFox does not seem to be able to handle in this specific combination. As FireFox is probably not very common anymore most people will not not encounter this problem...

MomosX commented 2 years ago

Having mentioned the bowser... i changed from Chrome to Edge and it works. On Chrome it doesn't. I'm on win 11, Chrome Version 99.0.4844.82 (Official Build) (64-bit).

TheDK commented 2 years ago

I checked again - everything works fine for me in Chrome (most recent version) on Windows Server 2019 as well as MacOS. Will test again on Win10 tomorrow, but that should not make a difference. For me Firefox is the problem on Win10 as well as Win2019 Srv.

I get a lot of errors in the Grafana add-on log when trying to access from Firefox on windows:

server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67)
logger=context t=2022-03-27T20:27:23.98+0200 lvl=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr="192.168.23.11, 172.30.32.1" time_ms=165 size=272 referer="http://192.168.23.15:8123/api/hassio_ingress/57ASMUVXUTGabMn4GzqIdrCXvpk3fG7-2P6-wDuHKxk/d/kOuP_Fggz/overview?orgId=1&refresh=30s"
server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67)
logger=context t=2022-03-27T20:27:24.03+0200 lvl=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr="192.168.23.11, 172.30.32.1" time_ms=11 size=398 referer="http://192.168.23.15:8123/api/hassio_ingress/57ASMUVXUTGabMn4GzqIdrCXvpk3fG7-2P6-wDuHKxk/d/kOuP_Fggz/overview?orgId=1&refresh=30s"
server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67)
logger=context t=2022-03-27T20:27:24.03+0200 lvl=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr="192.168.23.11, 172.30.32.1" time_ms=22 size=459 referer="http://192.168.23.15:8123/api/hassio_ingress/57ASMUVXUTGabMn4GzqIdrCXvpk3fG7-2P6-wDuHKxk/d/kOuP_Fggz/overview?orgId=1&refresh=30s"
server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67)
logger=context t=2022-03-27T20:27:24.04+0200 lvl=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr="192.168.23.11, 172.30.32.1" time_ms=95 size=354 referer="http://192.168.23.15:8123/api/hassio_ingress/57ASMUVXUTGabMn4GzqIdrCXvpk3fG7-2P6-wDuHKxk/d/kOuP_Fggz/overview?orgId=1&refresh=30s"

192.168.23.11 is the client running FireFox, .15 is the HA instance. Those errors are not in the log if I access with a different browser or FireFox on MacOS.

@frenck: As this does not happen when Grafana is accessed directly (only in HA "frame") not quite sure if this is something for you / the add-on? Anything else I can provide with regard to logs?

TheDK commented 2 years ago

And the detailed error in Grafana:

origin not allowed {"results":{"A":{"error":"db query error: pq: Syntaxfehler bei Ā»ORDERĀ«","frames":[{"schema":{"refId":"A","meta":{"executedQueryString":"WITH charging_process AS (\n SELECT id, end_date\n FROM charging_processes\n WHERE car_id = \n ORDER BY start_date DESC\n LIMIT 1\n)\nSELECT\n date AS \"time\",\n CASE WHEN charging_process.end_date IS NULL THEN charger_power\n ELSE 0\n END AS \"Power [kW]\"\nFROM charges, charging_process\nWHERE charging_process.id = charging_process_id\nORDER BY date DESC\nLIMIT 1;"},"fields":[]},"data":{"values":[]}}]}}}
Object
status:403
statusText:"Forbidden"
data:Object
message:"origin not allowed
{\"results\":{\"A\":{\"error\":\"db query error: pq: Syntaxfehler bei Ā»ORDERĀ«\",\"frames\":[{\"schema\":{\"refId\":\"A\",\"meta\":{\"executedQueryString\":\"WITH charging_process AS (\\n  SELECT id, end_date\\n  FROM charging_processes\\n  WHERE car_id = \\n  ORDER BY start_date DESC\\n  LIMIT 1\\n)\\nSELECT\\n  date AS \\\"time\\\",\\n  CASE WHEN charging_process.end_date IS NULL THEN charger_power\\n       ELSE 0\\n  END AS \\\"Power [kW]\\\"\\nFROM charges, charging_process\\nWHERE charging_process.id = charging_process_id\\nORDER BY date DESC\\nLIMIT 1;\"},\"fields\":[]},\"data\":{\"values\":[]}}]}}}
"
error:"Forbidden"
response:"origin not allowed
{\"results\":{\"A\":{\"error\":\"db query error: pq: Syntaxfehler bei Ā»ORDERĀ«\",\"frames\":[{\"schema\":{\"refId\":\"A\",\"meta\":{\"executedQueryString\":\"WITH charging_process AS (\\n  SELECT id, end_date\\n  FROM charging_processes\\n  WHERE car_id = \\n  ORDER BY start_date DESC\\n  LIMIT 1\\n)\\nSELECT\\n  date AS \\\"time\\\",\\n  CASE WHEN charging_process.end_date IS NULL THEN charger_power\\n       ELSE 0\\n  END AS \\\"Power [kW]\\\"\\nFROM charges, charging_process\\nWHERE charging_process.id = charging_process_id\\nORDER BY date DESC\\nLIMIT 1;\"},\"fields\":[]},\"data\":{\"values\":[]}}]}}}
"
config:Object
url:"api/ds/query"
method:"POST"
data:Object
requestId:"Q144"
retry:0
headers:Object
hideFromInspector:false
message:"origin not allowed
{\"results\":{\"A\":{\"error\":\"db query error: pq: Syntaxfehler bei Ā»ORDERĀ«\",\"frames\":[{\"schema\":{\"refId\":\"A\",\"meta\":{\"executedQueryString\":\"WITH charging_process AS (\\n  SELECT id, end_date\\n  FROM charging_processes\\n  WHERE car_id = \\n  ORDER BY start_date DESC\\n  LIMIT 1\\n)\\nSELECT\\n  date AS \\\"time\\\",\\n  CASE WHEN charging_process.end_date IS NULL THEN charger_power\\n       ELSE 0\\n  END AS \\\"Power [kW]\\\"\\nFROM charges, charging_process\\nWHERE charging_process.id = charging_process_id\\nORDER BY date DESC\\nLIMIT 1;\"},\"fields\":[]},\"data\":{\"values\":[]}}]}}}
"
MomosX commented 2 years ago

whne trying to access from Chrome i get the same error repeating multiple times in the Grafan addon log:

server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67) server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67) server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67) server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67) server.go:3160: http: superfluous response.WriteHeader call from github.com/grafana/grafana/pkg/web.(*responseWriter).WriteHeader (response_writer.go:67)

When accesing through Edge the log stays clear, no error

TheDK commented 2 years ago

@frenck Just a question: Is that something you want to have a look at or do we chalk that up to strange browser behaviour and all use Chrome? :)

TheDK commented 2 years ago

A quick update as this gets stranger over time:

Prod environment:

System Health

version core-2022.4.7
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.108
arch aarch64
timezone Europe/Berlin
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4910 Installed Version | 1.24.5 Stage | running Available Repositories | 1050 Downloaded Repositories | 13
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 12. Mai 2022, 02:00 relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | false remote_server | eu-west-2-3.ui.nabu.casa can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 7.6 -- | -- update_channel | stable supervisor_version | supervisor-2022.05.0 docker_version | 20.10.9 disk_total | 113.9 GB disk_used | 15.0 GB healthy | true supported | true board | odroid-n2 supervisor_api | ok version_api | ok installed_addons | File editor (5.3.3), Check Home Assistant configuration (3.10.0), FTP (4.5.0), Terminal & SSH (9.4.0), Log Viewer (0.13.0), Samba share (9.6.1), Node-RED (11.1.2), ESPHome (2022.3.1), Glances (0.15.0), Grafana (7.5.2), Z-Wave JS to MQTT (0.39.0), TeslaMate (0.17.2)
Dashboards dashboards | 3 -- | -- resources | 4 views | 18 mode | storage

Test environment:

System Health

version core-2022.4.7
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.108
arch x86_64
timezone Europe/Berlin
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4910 Installed Version | 1.22.0 Stage | running Available Repositories | 1050 Downloaded Repositories | 3
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 7.6 -- | -- update_channel | stable supervisor_version | supervisor-2022.05.0 docker_version | 20.10.9 disk_total | 30.8 GB disk_used | 5.6 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | File editor (5.3.3), Terminal & SSH (9.4.0), Log Viewer (0.12.2), ESPHome (2022.1.2), PostgreSQL (1.0.0), Grafana (7.5.2), TeslaMate (0.17.2)
Dashboards dashboards | 2 -- | -- resources | 1 views | 2 mode | storage

Grafana has the same dashboard imported an running against the same PostgreSQL DB (not installed on either of the HA environments, different server). Results:

FireFox 100.0 (64-Bit) on Win10: Prod Error as above, Test working fine (tested on two different machines) FireFox 100.0 (64-Bit) on Win Server 2019: All working fine

Chrome and Edge working generally just fine...

I can't figure out what the difference is that produces the error above...

TheDK commented 2 years ago

Getting closer: Accessing it over the Nabu Casa cloud feature also works, accessing it directly with the local IP of HA without SSL does not work.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

TheDK commented 2 years ago

Problem still persists on latest versions. It was also reproduced by others (see linked issue).

frenck commented 2 years ago

I've today tried to reproduce this once again, and I'm simply not capable of reproducing this on various setups and browsers.

It seems Windows is a common theme? Anyways, I'm not able to test that as I do not own or have access to Windows machines (also refuse to touch one).

MomosX commented 2 years ago

If i can help let me know how please.

On thing is for sure. It used to work, after it did not.

Here is the error as it is now.

image

TheDK commented 2 years ago

It seems Windows is a common theme? Anyways, I'm not able to test that as I do not own or have access to Windows machines (also refuse to touch one).

Yes, I believe it is only the combination Windows 10 (not 2019 Srv btw) / FireFox / delivery via HA using NGINX. All other combinations seem to work fine, even this one using Chrome. So I understand if that is not something you want to sink time in...

MomosX commented 2 years ago

I have no proof , nor the knowledge to be sure, but i think it is not browser related. For me the error above is on Chrome. Edge works fine.
Also , accesing Grafana directly on the 3000 port on Chrome works also. Standard HA OS install with influx and grafana, no customizations.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!