Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming via PI WebAPI websocket #99

Open
txjmb opened this issue Jan 18, 2023 · 4 comments
Open

Streaming via PI WebAPI websocket #99

txjmb opened this issue Jan 18, 2023 · 4 comments

Comments

@txjmb
Copy link

txjmb commented Jan 18, 2023

Does the plugin currently have the ability to stream data via WebAPI Websocket? It would be very valuable to have a streaming connection to get real-time updates from PI server, and could be more timely, efficient, and easier on the server than polling. This would fall into the feature request category if it is not currently supported.

Relevant documentation from Grafana:
https://grafana.com/docs/grafana/latest/developers/plugins/build-a-streaming-data-source-plugin/

Documentation on channels can be found in the PI WebAPI built-in documenation at /piwebapi/help/topics/channels.

@complacentsee
Copy link
Contributor

complacentsee commented Jan 22, 2023

I took a rough look at this (ee7dbda), and I think the improvements are are not offsetting the significant issues it comes with. The biggest challenge is that it only makes sense with the Access parameter set to "Browser" at the moment. The "Server" option has no way to proxy the websocket connection using your grafana server, and the websocket needs to be opened directly from your browser.

Without trying to speak for the developer team, I think this function would make more sense if the plugin was updated with a backend server component.

@complacentsee
Copy link
Contributor

Actually, I was wrong. You can pass the websocket traffic through the proxy like this: 5c27572.

@txjmb
Copy link
Author

txjmb commented Jan 23, 2023

Thank you so much for looking into this so quickly. Sounds like maybe there's a way forward on this?

If I can help in any way, please let me know. I can check out your commit and see if I can find any issues.

@txjmb
Copy link
Author

txjmb commented Jan 23, 2023

One additional thing we would want to do besides connecting the websocket with the "includeIntitialValues" flag is to do a simple query first to determine size of the CircularDataFrame and to fill the CircularDataFrame with back data from the dashboard date range (say, for instance that the dashboard showed the last few hours to now). Then, any additional data that comes in on the websocket would be added to the CircularDataFrame if it falls inside the date range.

I can confirm with the "Live Measurements" Grafana streaming demo data source that the CircularDataFrame is indeed...circular. The data rolls when date range is set to "last x minutes". Makes perfect sense, and shouldn't really confuse users. It's an open question if we would want to have the UI include an option to "Use websocket", or just make it do that automatically, as I can't really think of a downside, unless that feature is explicitely blocked or turned off for a particular user on their WebAPI server
. The CircularDataFrame could still be used if they choose not to. If they are querying a range in the past, it will behave just like a regular query, since nothing would come in on the websocket that would fall into the query range and therefore would not be added to the data frame.

This would be a very good add for our industry (power) as some data is updated as often as every 4s or less, and would greatly reduce the load on the WebAPI servers when users want to view real-time data in near real-time (which would, without this feature, mean they would have to query the server every few seconds, with all the round-trip and querying overhead).

@coderReview coderReview added this to the Version 5.0.0 milestone Aug 15, 2023
@coderReview coderReview removed this from the Version 5.1.0 milestone Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants