-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(new sink): initial websocket_server
sink
#22213
feat(new sink): initial websocket_server
sink
#22213
Conversation
This adds a new sink, similar to `websocket` which acts like a client, while this one acts as a server. It currently broadcasts messages to all currently connected clients.
I have added customizable auth handler in this PR, but I can take it out into a separate PR if needed. This is also missing some tests and some metrics. I will probably also work on an optional event buffer to enable replays for some clients. That one might be more complex, so I wanted to put it off for now, to keep the initial PR simple. |
websocket_listener
sinkwebsocket_listener
sink
If it's not too much effort, please do. It should make reviewing faster. It's just me reviewing PRs for this month 😅 |
Oh 😄 |
Oh and sorry, I just saw the other part of the comment. Yeah, it causes duplication, my idea was to reuse it across these components, but didn't want to make too many changes in this PR. I guess if I move it to a separate PR, then changing these out should be okay. |
This adds `custom` auth strategy for components with HTTP server (`http_server`, `datadog_agent`, `opentelemetry`, `prometheus`) besides the default basic auth. This is a breaking change because `strategy` is now required for auth - for existing configurations `strategy: "basic"` needs to be added. Related: vectordotdev#22213
Would it make more sense to name this |
👍 |
websocket_listener
sinkwebsocket_server
sink
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
website/cue/reference/components/sinks/base/websocket_server.cue
Outdated
Show resolved
Hide resolved
Co-authored-by: Sandra (neko) <[email protected]>
@neko-dd sorry for the late reply. I have applied one of the suggestions, which was directly related to things added in this PR. The rest of it has been generated automatically from other things that I have used (which are standard for all sinks) and you can see that documentation already live on almost all of the sinks. Maybe these should be fixed in a separate PR? Because if I fixed the here, I would generate too many changes that are not really related to this (it would change docs for all sinks). |
…er (#22236) * feat(sources)!: add custom auth strategy for components with HTTP server This adds `custom` auth strategy for components with HTTP server (`http_server`, `datadog_agent`, `opentelemetry`, `prometheus`) besides the default basic auth. This is a breaking change because `strategy` is now required for auth - for existing configurations `strategy: "basic"` needs to be added. Related: #22213 * Generate components docs * Add changelog entry * Rename `user` to `username` to match old config * Apply docs suggestions from code review Co-authored-by: Esther Kim <[email protected]> * Update all docs based on suggestions * Prevent breaking change by defaulting to `basic` strategy for `HttpServerAuthConfig` * Remove breaking change flag on changelog entry * Add missing docs to `common/http/error` * Make tests clearer by using `panic` instead of matching enum variant * Move out `VRL` auth handling into a separate function for readability * Clean up changelog text Co-authored-by: Pavlos Rontidis <[email protected]> * Move test only functions in `server_auth` to `tests` module * Return serde tag for correct docs generation --------- Co-authored-by: Esther Kim <[email protected]> Co-authored-by: Pavlos Rontidis <[email protected]>
Ah yes, this is coming back to me 👍. Did we merge the master with those changes in this PR? If yes, please resolve those comments. |
Yes, but now looking at them, it seems that I have missed some of them. I will open up another PR with these. |
Co-authored-by: Pavlos Rontidis <[email protected]>
Actually, it seems that I just forgot to regenerate documentation. It should all be alright now. |
Wonderful, happy to see this merged. Optional request @esensar: can we add a "How it works" section with the steps you outlined in the test plan? The community has been finding these useful. |
Of course! I will add that in tomorrow. Do you think something like that would be useful for #22236 too? Or is the included documentation enough. Also, I planned on opening more PRs related to this sink in the following days and I think these could benefit even more from that section (if they are accepted of course). |
Thanks! Yes, more usage examples are important. They help reduce user frustration and also our KTLO cost. |
…ver` This adds a message buffer to `websocket_server`, backed by a ring buffer, which hold a set maximum number of messages to replay to clients that connect late, or re-connect after losing connection. Messages are replayed based on `last_received` query parameter. Related: vectordotdev#22213
…_server` docs Related: vectordotdev#22213
Summary
This adds a new sink, similar to
websocket
which acts like a client, while this one acts as a server. It currently broadcasts messages to all currently connected clients.It might make sense to add some kind of buffer and allow clients to catch up to missed messages, or something like that, but I wanted to leave such complications for further PRs.
This also adds customizable authentication using VRL, which would allow us to use custom VRL scripts to check auth, meaning we no longer use hardcoded basic auth and can use enrichment tables to look for credentials.
Change Type
Is this a breaking change?
How did you test this PR?
Started up vector with the following configuration:
Connected to the server with websocat and observed that events are sent to the client. I have also tested auth in this way, by defining auth header using
websocat
.Does this PR include user facing changes?
Checklist
make check-all
is a good command to run locally. This check isdefined here. Some of these
checks might not be relevant to your PR. For Rust changes, at the very least you should run:
cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo nextest run --workspace
(alternatively, you can runcargo test --all
)Cargo.lock
), pleaserun
dd-rust-license-tool write
to regenerate the license inventory and commit the changes (if any). More details here.