Skip to content
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

[Filebeat] httpjson - cannot send empty json object in body #33961

Closed
andrewkroh opened this issue Dec 6, 2022 · 3 comments · Fixed by #38290
Closed

[Filebeat] httpjson - cannot send empty json object in body #33961

andrewkroh opened this issue Dec 6, 2022 · 3 comments · Fixed by #38290
Assignees
Labels
enhancement Filebeat Filebeat Team:Security-Service Integrations Security Service Integrations Team

Comments

@andrewkroh
Copy link
Member

I want to be able to send an empty object in the body of a POST request. This is what my desired request would look like.

POST / HTTP/1.1
Host: localhost:8888
User-Agent: Elastic-Filebeat/8.7.0 (darwin; arm64; 2fc3e81eb31eefeb973bbffbf6d48e11327f9019; 2022-12-06 12:42:07 +0000 UTC)
Content-Length: 2
Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip
Connection: close

{}

But the input always writes an empty body (content-length 0) instead of an empty object {} when I try to configure this. I see there is an explicit empty check performed when encoding the output. 1

    # WRONG: generates empty body
    request.body: {}
    # ERROR: cannot target body directly
    request.transforms:
      - set:
          target: body
          value_type: json
          value: '{}'
    # WRONG: generates empty body
    request.transforms:
      - set:
          target: body.foo
          value: 'bar'
      - delete:
          target: body.foo

Footnotes

  1. https://github.com/elastic/beats/blob/ba3bce42590dbf722061d7d92bfdb0bd903e9014/x-pack/filebeat/input/httpjson/encoding.go#L106-L108

@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic
Copy link

botelastic bot commented Dec 6, 2023

Hi!
We just realized that we haven't looked into this issue in a while. We're sorry!

We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1.
Thank you for your contribution!

@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Filebeat Filebeat Team:Security-Service Integrations Security Service Integrations Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants