-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
x-pack/filebeat/input: Fix truncation of bodies in request tracing #42327
x-pack/filebeat/input: Fix truncation of bodies in request tracing #42327
Conversation
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations) |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an excellent commit message. Thank you.
The default maximum file size of 1MB gives a default maximum body size
of 100kB.
I find this behavior a bit surprising. I would have expected that if I needed to capture a full 5 MiB response body that I would need to increase the max size to something a little larger than 5 MiB, but not 10x the size. What do others think? At a minimum, I think we need to mention this behavior in the documentation associated with the tracer settings.
This pull request is now in conflicts. Could you fix it? 🙏
|
@andrewkroh I get that perspective. There are two things that make me lean towards the current version: Often getting several responses is more important than getting full response bodies. One per file isn't a great experience. If you're getting truncated, you can double the limit (or better, shorten the page length) until you get what you need. More importantly, since we're doing the truncation on the raw data, we need a fair bit of spare space to avoid problems. The real-world JSON I checked expanded by 15%, but it could need significantly more. A body of backslashes would double in size and bytes encoded as It would be nice to truncate to a specific length as the data is written into the log but that's a much more complicated change. I'm interested to know what others think. If we go with this version I can improve the documentation. |
@chrisberkhout , here are my thoughts. Couple of things that may impact us.
|
6ae4006
to
73e639a
Compare
As discussed in the team meeting, we'll go with the current approach unless @efd6 has a better idea. I've updated the documentation to be clear about the body limit being 10% of the file size limit. I added a The HTTP Endpoint truncation always limits request bodies to 10kiB. That behavior is unchanged by this PR but I noted it in the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
…42327) When logging request traces, truncate the request/response body to 10% of the maximum log file size. Previously, bodies were truncated to the maximum file size, less 10kB. 10kB is a reasonable number for the other trace details, but space is also required for encoding the body data as a JSON string value. One example JSON body was 15% larger after encoding, but the 10kB margin is 1% or less of the total limit. A body approaching the size limit would typically generate a log entry that exceeded the limit. Truncating large log entries to fit the file size limit means there may only be one such entry per file. By truncating body data to 10% of the file limit, we can expect to see entries for several request/response pairs in each file. The default maximum file size of 1MB gives a default maximum body size of 100kB. The behavior of request tracing for the HTTP Endpoint input is unchanged: it always truncates request bodies to a size of 10kiB. (cherry picked from commit 97c6f92)
…42327) (#42440) When logging request traces, truncate the request/response body to 10% of the maximum log file size. Previously, bodies were truncated to the maximum file size, less 10kB. 10kB is a reasonable number for the other trace details, but space is also required for encoding the body data as a JSON string value. One example JSON body was 15% larger after encoding, but the 10kB margin is 1% or less of the total limit. A body approaching the size limit would typically generate a log entry that exceeded the limit. Truncating large log entries to fit the file size limit means there may only be one such entry per file. By truncating body data to 10% of the file limit, we can expect to see entries for several request/response pairs in each file. The default maximum file size of 1MB gives a default maximum body size of 100kB. The behavior of request tracing for the HTTP Endpoint input is unchanged: it always truncates request bodies to a size of 10kiB. (cherry picked from commit 97c6f92) Co-authored-by: Chris Berkhout <[email protected]>
Proposed commit message
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues