golioth / grafana-websocket-plugin

Apache License 2.0
33 stars 13 forks source link

How to send initial JSON payload? #19

Open mafux777 opened 2 years ago

mafux777 commented 2 years ago

Relatively new to Websockets. Let's say I need to send the following JSON payload to the WSS endpoint:

url = "wss://kintsugi-rpc.dwellir.com" from pprint import pprint

payload = json.dumps( { "id": 1, "jsonrpc": "2.0", "method": "vaultRegistry_getPremiumRedeemVaults", "params": [] } )

How do I that here?

chireia commented 1 year ago

I'm not sure I understood. But you should have the plugin installed on Grafana, I can be used both on a local instance or on the cloud version. Then you should create a data source targeting your ws endpoint and use it on a dashboard/widget to grab the data and display as you need.

Your question made me think that you was trying to use it as a package for you application, and it's not made for that. It's a plugin for data visualization that works only with Grafana.

Tin-Joy59 commented 1 year ago

@chireia I think you misunderstood the question. I too want to send data to a websocket in order to subscribe to a subset of events.

Does the plugin offer an equivalent of ws.send()? And if yes, how to do it?

adam1231231 commented 1 year ago

also interested, @TinJoy59 did you figure it out?

chireia commented 1 year ago

Sorry @TinJoy59 and @adam1231231 , I don't think I understood it yet. Would you mind providing me more information or even screenshots of what you're trying to accomplish?

But answering your question:

Does the plugin offer an equivalent of ws.send()?

A: No, it's just a listener for WS messages.

chireia commented 1 year ago

Though, that might be a good new feature for the plugin, would you be interest in this addition? Is there another way to do it using some other plug-in/built-in Grafana?

adam1231231 commented 1 year ago

@chireia so some websockets require a subscription message where you send a json or something like {SUBSCRIBE : "user 1234"} or something, I think the majority of websockets require a subscription messages so this plug-in is missing "send a message on connection " kind of feature, I'm using prometheus now anyway but thought this little add on for this product would be nice

andrewsiah commented 1 year ago

Hi @adam1231231, did you end up using Prometheus as a substitute for this plugin when needing subscriptions for websockets? Thanks

0q2 commented 1 year ago

This is pretty basic functionality and should have been one of the first things implemented imo.

MohammedAiyub commented 3 months ago

Hi, is above issue fixed? this is mandatory to add initial subscription messages.