redpanda-data / redpanda-data/benthos

status code of a `http_client` under output.

Open
#213 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

http question
Dominant language
Go
Stars
571
Forks
120
Avg merge
2d 1h
Merged PRs (30d)
18

Description

I am encountering an issue when attempting to capture the http_status_code from an HTTP endpoint using Benthos. Despite configuring the extract_headers to include the http_status_code, the logged output consistently returns for the status code.

this is the method is tried.
i used "http_status_code" because i saw in the code, the http_status_code is being set in the repo:
https://github.com/redpanda-data/benthos/blob/main/internal/httpclient/client.go#L219

I have a benthos/connect config like this:

http:
  address: 0.0.0.0:4195
input:
  http_server:
    address: ""
    path: /endpoint
    allowed_verbs:
      - POST
output:
  http_client: 
    url : <endpoint> (configured to give 200 for now)
    verb : POST
    propagate_response : true
    extract_headers : 
      include_prefixes: [ "http_status_code" ]
  processors :
    - log:
        fields_mapping: |
          root.event_type = this.type
          root.event_id = this.id
          root.status_code = meta("http_status_code")

the output log i'm recieving is :

 path=root.output.processors.0 status_code="<nil>"

can anyone please guide me here ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction configuration in the issue and inspect internal/httpclient/client.go around line 219, where http_status_code is set. Trace how extract_headers and propagate_response expose that value to meta("http_status_code") in the output processor. Done means the configured endpoint's status code appears in the log instead of nil.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.