fix: use max_req_body_bytes field in custom_format #11771
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem description
The customer uses the kafka-logger plug-in and configures max_req_body_bytes and max_resp_body_bytes respectively, and the sizes of the request and response bodies exceed the configured values. However, in the log content actually uploaded to kafka, the response body is truncated, but the request body is not truncated. Perform truncation.
Reproduction steps
Configure plugin_metadata for kafka-logger and set a custom log format. The log format contains $request_body
Enable the kafka-logger plug-in in the global plug-in or route or service, and configure max_req_body_bytes and max_resp_body_bytes
The client initiates a request, the request body size is greater than max_req_body_bytes, and hits the kafka-logger plug-in
Viewing the log in kafka, you can see that the content of request_body is the complete request body and is not truncated.
Fix: Make sure the field is used in custom_format as well
Fixes # (issue)
Checklist