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] http trace logger - truncate response bodies larger than request.tracer.maxsize #37826

Closed
andrewkroh opened this issue Feb 1, 2024 · 2 comments · Fixed by #37836
Closed
Assignees
Labels
discuss Issue needs further discussion. enhancement Filebeat Filebeat Team:Service-Integrations Label for the Service Integrations team

Comments

@andrewkroh
Copy link
Member

andrewkroh commented Feb 1, 2024

Problem: When using request.tracer.filename in CEL or httpjson, if the logged message is larger than the maximum size allowed for a log file then the message is discarded by Zap.

Proposal: Provide the max size as a hint to the httplog package and when the http.{request,response}.body.content is larger than the max size (minus some safety margin to account for the rest of the log message body) then truncate the content and add a truncation indicator field. The missing response is confusing to developers. So including anything (even if truncated) is better than nothing.

It feels a little hacky to me, but I could not find an easy way to check for errors from the logger and react to that.

@andrewkroh andrewkroh added Filebeat Filebeat Team:Service-Integrations Label for the Service Integrations team enhancement discuss Issue needs further discussion. labels Feb 1, 2024
@andrewkroh andrewkroh changed the title [Filebeat] http trace logger - truncate response bodies that are bigger than request.tracer.maxsize [Filebeat] http trace logger - truncate response bodies larger than request.tracer.maxsize Feb 1, 2024
@bhapas
Copy link
Contributor

bhapas commented Feb 1, 2024

Will it be possible to truncate the content value based on size? Like if http.response.body.content is 3MB , should the truncate happen based on size to cut off less than 1 MB?

@andrewkroh
Copy link
Member Author

Yes, we control the value that goes into the http.response.body.content field. So if we want to truncate it we can do that at

zap.ByteString("http.response.body.content", body),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Issue needs further discussion. enhancement Filebeat Filebeat Team:Service-Integrations Label for the Service Integrations team
Projects
None yet
3 participants