Skip to content

Conversation

@keuin
Copy link

@keuin keuin commented Jan 1, 2026

Summary

This patch adds HTTP response body peek logic, reading for at most 1024 UTF-8 characters from HTTP response. It uses this utility function to log response from sink, when sink reports error. This helps user find out why the sink is not working more quickly.

Vector configuration

I use a local ClickHouse server as sink, standard input as source:

[sources.in]
type = "stdin"
decoding.codec = "json"

[sinks.out]
type = "clickhouse"
inputs = ["in"]
endpoint = "http://localhost:8123" 
database = "default"
table = "test_table"
auth.strategy = "basic"
auth.user = "default"
auth.password = ""

How did you test this PR?

I spin up the test sink ClickHouse, which talks to Vector via HTTP.
I created test table with:

create table test_table(value Int64);

I configured Vector to write to that table. Then I spin up Vector, wrote data in stdin:

{"value":"some_value"}

Since the data cannot be converted to Int64, ClickHouse reported an error. Without this patch, Vector won't tell you why. With this patch, Vector clearly showed what caused the error:

$ ./target/debug/vector --config test.toml
2026-01-01T09:11:04.813273Z  INFO vector::app: Log level is enabled. level="info"
2026-01-01T09:11:04.814745Z  INFO vector::app: Loading configs. paths=["test.toml"]
2026-01-01T09:11:04.823813Z  INFO vector::sources::file_descriptors: Capturing stdin.
2026-01-01T09:11:05.221184Z  INFO vector::topology::running: Running healthchecks.
2026-01-01T09:11:05.221550Z  INFO vector: Vector has started. debug="true" version="0.53.0" arch="aarch64" revision=""
2026-01-01T09:11:05.221584Z  INFO vector::app: API is disabled, enable by setting `api.enabled` to `true` and use commands like `vector top`.
2026-01-01T09:11:05.223805Z  INFO vector::topology::builder: Healthcheck passed.
{"value":"some_value"}
2026-01-01T09:11:12.763568Z  INFO vector_common::shutdown: All sources have finished.
2026-01-01T09:11:12.763684Z  INFO vector_common::shutdown: Internal log [All sources have finished.] is being suppressed to avoid flooding.
2026-01-01T09:11:12.763780Z  INFO vector::app: All sources have finished.
2026-01-01T09:11:12.763838Z  INFO vector: Vector has stopped.
2026-01-01T09:11:12.764996Z  INFO vector::topology::running: Shutting down... Waiting on running components. remaining_components="out" time_remaining="59 seconds left"
2026-01-01T09:11:12.881649Z ERROR sink{component_kind="sink" component_id=out component_type=clickhouse}:request{request_id=1}: vector::sinks::util::retries: Not retriable; dropping the request. reason="response status: 400 Bad Request, body: Code: 27. DB::Exception: Cannot parse input: expected '\"' before: 'some_value\"}\\n': (while reading the value of key value): (at row 1)\n: While executing ParallelParsingBlockInputFormat. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 25.11.2.24 (official build))\n"
2026-01-01T09:11:12.881979Z ERROR sink{component_kind="sink" component_id=out component_type=clickhouse}:request{request_id=1}: vector_common::internal_event::service: Service call failed. No retries or retries exhausted. error=None request_id=1 error_type="request_failed" stage="sending"
2026-01-01T09:11:14.493112Z ERROR sink{component_kind="sink" component_id=out component_type=clickhouse}:request{request_id=1}: vector_common::internal_event::component_events_dropped: Events dropped intentional=false count=1 reason="Service call failed. No retries or retries exhausted."

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

@keuin keuin requested a review from a team as a code owner January 1, 2026 09:23
@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Jan 1, 2026
@github-actions
Copy link

github-actions bot commented Jan 1, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@keuin
Copy link
Author

keuin commented Jan 1, 2026

I have read the CLA Document and I hereby sign the CLA

@keuin keuin changed the title feat(sink): log response body when HTTP response failed feat(sinks): log response body when HTTP response failed Jan 1, 2026
@keuin keuin force-pushed the feature/log-http-response-error branch 4 times, most recently from acf7265 to d27d01f Compare January 1, 2026 15:20
@keuin keuin force-pushed the feature/log-http-response-error branch from d27d01f to 35f0bf7 Compare January 1, 2026 15:25
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.

1 participant