Subscription to Grafana live dashboard channel fails

Hello everyone,

I managed to establish a websocket connection to grafana live with postman and also with a python script.

But that’s it, subscribing to a dashboard channel fails. The grafana live documentation answers how the channel name should be build, but not exactly how the JSON must look like.

Grafana Live Channel Documentation

Here is the successful connection:
— request header —
GET /api/live/ws HTTP/1.1
Upgrade: websocket
Host: community.grafana.com
Origin: http://grafana.staged-by-discourse.com
Sec-WebSocket-Key: yfioVni/IDB7IRxF9vMZkg==
Sec-WebSocket-Version: 13
Connection: Upgrade
Authorization: Bearer eyJrIjoiUHpEQXhac09xekR6azV1YVhIOTUxc2IznHRBNGVGWmUiLCJuIjoiYXBpa2V5IiwiaWQiOjF9

— response header —
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: kjTAmCNhuUhNckPK7hFBw+qQkms=

JSONs i tried to send for subscription:
{“type”: “subscribe”, “channel”: “grafana/dashboard/ORrNDmCnk”}
{“message”: “subscribe”, “channel”: “grafana/dashboard/ORrNDmCnk”}
{“event”: “subscribe”, “channel”: “grafana/dashboard/ORrNDmCnk”}
{“subscribe”: “grafana/dashboard/ORrNDmCnk”}

But i only get {“reason”:“bad request”,“reconnect”:false} as response.
The ws connection itself works, but how does a correct subscription JSON look like??

Example subscription send/response:

Opened connection
++Sent raw: b’\x81\xba\x1fR\x19\xd5dpt\xb0l!x\xb2zp#\xf5=!l\xb7l1k\xbc}7;\xf9?pz\xbd~<w\xb0sp#\xf5=6x\xa6w0v\xb4m66\x9aM W\x91r\x11w\xbe=/’
++Sent decoded: fin=1 opcode=1 data=b’{“message”: “subscribe”, “channel”: “dashboard/ORrNDmCnk”}’
++Rcv raw: b’\x88,\x0b\xbb{“reason”:“bad request”,“reconnect”:false}’
++Rcv decoded: fin=1 opcode=8 data=b’\x0b\xbb{“reason”:“bad request”,“reconnect”:false}’
++Sent raw: b’\x88\x82\xb8=yw\xbb\xd5’
++Sent decoded: fin=1 opcode=8 data=b’\x03\xe8’

@mgrimm Can you please give details on how the SubscribeStream and RunStream is written for your case?