-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Description
What happened:
Beginning from Grafana 6.6.0 we started seeing this issue where activating Loki in live mode explodes with a generic parsing error.
An unexpected error happened Details TypeError: Cannot read property 'slice' of null
Tracing the issue we found that Loki is throwing this message:
msg="Error in upgrading websocket" err="websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header"
What you expected to happen:
Grafana working correctly with Loki in live mode
How to reproduce it (as minimally and precisely as possible):
There's no particular way to reproduce the issue. Just using the Live mode for Loki with Grafana v6.6.0 or later.
Anything else we need to know?:
We are stuck in version 6.5.3 and have not found anything in our configuration that could fix this issue. We have an nginx correctly setup between Grafana and Loki and it has been working great until now.
Any help would be very appreciated.
Environment:
- Grafana version: 6.6.0 - 6.7.0
- Data source type & version: Loki 1.2.0
- OS Grafana is installed on: K8S
- User OS & Browser: Mac in all browsers
- Grafana plugins: None
- Others: None
Activity
aknuds1 commentedon Mar 19, 2020
Do you mind rewriting the issue to abide by our standard issue template?
danieldabate commentedon Mar 19, 2020
I used the issue template, I just deleted some of the parts that I don't think that apply to this issue. But I will add them. Thanks for the help.
quanterion commentedon Mar 24, 2020
Have the same error with Grafana 6.7.1 and Loki 1.3
Call stack is:
cordula-grau commentedon Mar 25, 2020
Same issue here, grafana 6.7.1 and loki 1.3, logcli is running fine in tail mode
noahrotheray commentedon Mar 26, 2020
Same issue:
Grafana 6.6.2
Loki 1.3
jongyllen commentedon Apr 3, 2020
Hi, when I try this with Grafana 6.7.2 the live logs for Loki works for me. Has this been resolved maybe?
danieldabate commentedon Apr 3, 2020
I just tested 6.7.2 but the issue is still happening. From what I know it does not happen to everyone.
torkelo commentedon Apr 3, 2020
Maybe you need to update Loki? What version of Loki are you using? Also try latest version of Grafana
torkelo commentedon Apr 3, 2020
Maybe you have proxy in front of Grafana that does not support websockets?
danieldabate commentedon Apr 3, 2020
Tried latest version of Grafana and Loki with no success.
I do have a proxy in front of Grafana and also a proxy between Grafana and Loki, but this setup is working great with Grafana 6.5.3, so proxies are not the problem. It breaks from Grafana 6.6.0. Maybe some change was introduced in that version that is not compatible with our setup.
Do you recall any changes introduced in this version that could be the source of the problem? Maybe endpoint changes or any other change? Not saying a bug, but maybe just a breaking change that we should be aware of.
danieldabate commentedon Apr 3, 2020
I found the issue!! It was an endpoint change like I said in the previous message.
Now Grafana is requesting this Loki's endpoint:
/loki/api/v1/tail
instead of the older:
/api/prom/tail
So any setup in the proxies related to the older version, like a
proxy_set_header Upgrade
, would not be applied from Grafana 6.6.0ivanahuckova commentedon Apr 23, 2020
Hello @danieldabate! I am glad that you were able to solve the problem. 🚀 I am going to close this issue as in the next release we are are going to stop supporting legacy Loki endpoints (before v1). As it is a breaking change, it is going to be communicated in the release notes.
1 remaining item
chusiang commentedon Apr 28, 2020
Thanks @danieldabate, you saved my some time.
7olstoy commentedon May 8, 2020
@ivanahuckova 7.0.0-beta3 still this issue
nginx-proxy
loki 1.4.1
s5unty commentedon May 9, 2020
Live mode requires websocket.
If nginx is used, websocket support is required
https://www.nginx.com/blog/websocket-nginx/
7olstoy commentedon May 9, 2020
@s5unty
Thank you, your link helped
jslay88 commentedon May 14, 2020
Just to help those coming here from a fresh Grafana and Loki deployment via Helm, when you add Loki to your Data Sources, check your logs on the loki pod and you will likely see errors about the Connection or Upgrade headers. You need to add two custom headers in the config for the Loki Data Source in Grafana.
Binyamse commentedon Oct 20, 2020
I am having this issue no proxy in the middle (between grafan and loki) added the two custom headers the issue persists.
saikatharryc commentedon Apr 20, 2021
I'm using ambassador Mappings, doing this worked for me, which means. for those not working, try allowing WebSocket connection upgrade. to their controllers/servers.
gurre commentedon Jan 19, 2022
Custom headers didn't solve it for me but here is the config:
I'm getting
parse error : syntax error: unexpected $end
fromGET /api/datasources/proxy/95/loki/api/v1/query_range
andWebSocketSubject.js:96 WebSocket connection to 'wss://loki.local/api/datasources/proxy/95/loki/api/v1/tail?query=%7Bjob%3D%22systemd-journal%22%7D' failed:
oleksii-boiko-ua commentedon Jun 9, 2023
we are having exact same issues when X-Scope-OrgID header contains more than 1 tenant id.
Grafana v9.5.3
Loki v2.8.2
jslay88 commentedon Jun 29, 2023
This is a completely different error than what the custom headers are supposed to solve.
Custom headers only solve the issue when the error states that it is a Connection or Upgrade header issue.
Jeremy-Boyle commentedon Jul 20, 2023
I was able to fix this by enabling
WebSocket
on the Grafana side along with the followingFor what its worth, my grafana instance is behind HTTPProxy with Contour.
Here's for nginx (https://www.civo.com/learn/using-websockets-with-ingress-controller)
My HTTPProxy is as follows.