Skip to content

feat(http sink): templateable uri #23288

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

jorgehermo9
Copy link
Contributor

@jorgehermo9 jorgehermo9 commented Jun 30, 2025

Closes #1155

Testing

First, spin up a dummy http server that will receive the requests of the http sink, for example, using dummyhttp

dummyhttp -v -p 8081

Then, using the following Vector config:

[sources.in]
type = "http_server"
address = "0.0.0.0:8080"
decoding.codec = "json"

[sinks.out]
type = "http"
inputs = ["in"]
uri = "http://localhost:8081/id/{{id}}"
encoding.codec = "json"
batch.timeout_secs = 5

We listen for incoming requests at 8080 and then forward them to localhost:8081 taking the id field of the events to render the uri.

Then, we send requests with a payload that contains that id field to the http source:

curl -X POST -d '{"id":5,"message":"test2"}' localhost:8080

and we can see requests reaching the dummyhttp server with the path /id/5
image

If we send multiple curl commands within the same batch time window (5s) we can see the events grouped in the same request (for example, sending 3 events with id=5 and 2 events with id=3)
image
image

@jorgehermo9 jorgehermo9 requested a review from a team as a code owner June 30, 2025 00:14
@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Jun 30, 2025
@github-actions github-actions bot added the domain: ci Anything related to Vector's CI environment label Jun 30, 2025

tokio::spawn(server);

sink.run_events([event]).await.unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't use run_and_assert_sink_error because there were 2 errors being emitted (ServiceCallError and SinkRequestBuildError), and this assert failed https://github.com/vectordotdev/vector/blob/master/lib/vector-common/src/event_test_util.rs#L31 because the assert just checks that there is just one event name that contains the word "Error"

events: &["Error"],

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to refactor it so we can re-use it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored in 83d8fa6, let me know what you think

@github-actions github-actions bot removed domain: sinks Anything related to the Vector's sinks domain: ci Anything related to Vector's CI environment labels Jun 30, 2025
@jorgehermo9 jorgehermo9 force-pushed the feature/templatable-uri-http-sink branch from 74e60b5 to 9c7993b Compare June 30, 2025 00:40
@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Jun 30, 2025
@jorgehermo9 jorgehermo9 changed the title feat: templatable uri in http sink feat: templateable uri in http sink Jun 30, 2025
@jorgehermo9 jorgehermo9 changed the title feat: templateable uri in http sink feat(http sink): templateable uri Jun 30, 2025
@pront
Copy link
Member

pront commented Jun 30, 2025

Hi @jorgehermo9, thank you for this PR! I will review it today. Please add a PR description a Vector config you used to test this.


tokio::spawn(server);

sink.run_events([event]).await.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to refactor it so we can re-use it here

@jorgehermo9
Copy link
Contributor Author

Hi @pront, thank you very much for your prompt review! I had no time today, but will address everything tomorrow; split the ConcurrementMap fix in another PR, open the two issues I mentioned, specifying a config to test this in the PR description... Than ks!

@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Jul 2, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Jul 4, 2025
@jorgehermo9
Copy link
Contributor Author

Please add a PR description a Vector config you used to test this.

Updated the PR's description with a test config & steps!

@jorgehermo9
Copy link
Contributor Author

Still have a few comments left, I'll address them through the week, I had busy days lately, sorry! I'll ping when everything is done :)

@pront
Copy link
Member

pront commented Jul 7, 2025

Still have a few comments left, I'll address them through the week, I had busy days lately, sorry! I'll ping when everything is done :)

👍 thanks!

@pront pront force-pushed the master branch 4 times, most recently from 1720078 to ffe54be Compare July 10, 2025 15:43
@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Jul 10, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Jul 13, 2025
@jorgehermo9
Copy link
Contributor Author

jorgehermo9 commented Jul 13, 2025

Hi @pront,

About the request_builder conversation (https://github.com/vectordotdev/vector/pull/23288/files/e5824624cabfeca1e30ef470ce25fea5abeda513#r2174023559)

I was mistaken and the event was being notified with EventStatus::Rejected. Fixed it in 618a8e8. The problem was that I was using Event::with_batch_notifier in the tests intead of Event::add_batch_notifier. I don't quite understand why Event::with_batch_notifier was not working as expected, as I saw it was being used in other places such as

stream.map(move |log| vec![log.with_batch_notifier_option(&batch)].into())
. Do you have any feedback about that previous usage? Or was it a bug?

And about the partitioned_batched issue, with 618a8e8 now the status is set to EventStatus::Delivered, opened #23366 to track this issue.

I think the only one thing left is the run_and_assert_sink_error refactor in this conversation #23288 (comment).

Sorry for the delay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: sinks Anything related to the Vector's sinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the http sink uri option templateable
3 participants