Skip to content

Websocket input plugin#8867

Closed
srebhan wants to merge 10 commits intoinfluxdata:masterfrom
HRI-EU:websockets_inputs
Closed

Websocket input plugin#8867
srebhan wants to merge 10 commits intoinfluxdata:masterfrom
HRI-EU:websockets_inputs

Conversation

@srebhan
Copy link
Copy Markdown
Member

@srebhan srebhan commented Feb 16, 2021

Required for all PRs:

  • Associated README.md updated.
  • Has appropriate unit tests.

This input plugin supports gathering data from a websocket endpoint. It has two operation modes, one event-based mode waiting for the server to push data and one actively gathering the data in regular intervals.

@telegraf-tiger telegraf-tiger bot added new plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Feb 16, 2021
Copy link
Copy Markdown
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤝 ✅ CLA has been signed. Thank you!

@ssoroka
Copy link
Copy Markdown
Contributor

ssoroka commented Feb 16, 2021

should there be a parameter for which mode is expected? Could you have both an event and poll mode with a trigger body (event using it just to trigger once?)

@srebhan
Copy link
Copy Markdown
Member Author

srebhan commented Feb 17, 2021

@ssoroka currently handshake_body is sent after establishing connection (once). The trigger_body is sent on each gather cycle, so currently I use trigger_body as switch between using Gather() (sampling) and Start() with listen() (event-based) for acquisition. The reason is that I have two use-cases, one where we need to send a handshake-message and then receive data upon change of data and another one, where we need to send a handshake-message (like registering the client) and then a trigger-message to trigger sending of data.
We even might cover a third use-case if we allow multiple handshake-messages...

What do you suggest?

@srebhan
Copy link
Copy Markdown
Member Author

srebhan commented Feb 18, 2021

!retry-failed

Copy link
Copy Markdown
Contributor

@jessingrass jessingrass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at settings yet, but would appreciate feedback on the library choice when you have time!

- modernc.org/libc [BSD 3-Clause "New" or "Revised" License](https://gitlab.com/cznic/libc/-/blob/master/LICENSE)
- modernc.org/memory [BSD 3-Clause "New" or "Revised" License](https://gitlab.com/cznic/memory/-/blob/master/LICENSE)
- modernc.org/sqlite [BSD 3-Clause "New" or "Revised" License](https://gitlab.com/cznic/sqlite/-/blob/master/LICENSE)
- nhooyr.io/websocket [MIT License](https://github.com/nhooyr/websocket/blob/master/LICENSE.txt)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about the reason behind this websocket library choice vs gorilla? We already have gorilla in use, so would like to understand your reasoning.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jessingrass, I've chosen this one as it seemed simpler for my use-case and didn't notice we already have gorilla. If you want me to change I can try...

@srebhan srebhan mentioned this pull request May 18, 2021
2 tasks
@reimda
Copy link
Copy Markdown
Contributor

reimda commented May 18, 2021

Hi Sven, I just got a chance to look at this. I like it and have some questions. How do you intend to use this input? Are you going to write a custom websocket server or use an existing service? Many websocket servers require authentication and have a custom request protocol that might be too complex for the trigger_body mechanism.

I also think it would be good to switch this to gorilla/websocket so telegraf uses only one websocket library. I don't see any other plugins that use gorilla/websocket currently but some of our module dependencies use it, and the recent websocket output uses it.

@srebhan
Copy link
Copy Markdown
Member Author

srebhan commented May 20, 2021

@reimda I use it for an existing service that can be handled with the means provided. Another important use-case is to connect two telegrafs in restricted (NATed) networks. Using the new websocket output plugin, we can connect two instances where an "inner" telegraf has to establish connects to an "outer" telegraf. Kind of a proxy setups with connection restrictions in place...
However, I agree that this cannot cover arbitrary protocols, but it will be sufficient for the two use-cases above.

Currently, converting this to gorilla is of low priority here due to limited time. So if anybody (looks at @FZambia ;-)) wants to step up on it, any help is appreciated. :-)

@reimda
Copy link
Copy Markdown
Contributor

reimda commented May 20, 2021

I use it for an existing service that can be handled with the means provided. Another important use-case is to connect two telegrafs in restricted (NATed) networks. Using the new websocket output plugin, we can connect two instances where an "inner" telegraf has to establish connects to an "outer" telegraf.

It would be useful to add some usage examples to the readme. Maybe these would be good examples to add if you get a chance. Thanks!

@srebhan
Copy link
Copy Markdown
Member Author

srebhan commented Apr 28, 2022

Will close this as there seems to be no great interest in this PR. If anyone wants to continue here, please feel free to take the code and work on it.

@srebhan srebhan closed this Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants