-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
request help: kafka logger supports logging request body #5343
Comments
core.request.get_body and core.response.hold_body_chunk can't �be used in 'log_by_lua' phase,it seems that we can logging log it in other phase or set request_body and response_body in ctx. Does it have a better way? |
Do this in an early phase, say, |
Other phase like filter_by_lua may rewrite request and response by other plugin. If we get request_body and response_body in filter_by_lua and set it in ctx,it may cause performance issue |
get request body in |
Yes. The log of body is expensive. So we should only log it if need.
In practice, it is not a problem. The gzip filter runs after lua filter, so there is no way to log the gzipped response body in the Lua. However, very few people want to log the gzipped body instead of the original one. If people need a 100% real body sent to the client, they should do it in another proxy or a traffic capture sidecar. |
Other plugin like |
Since the kafka-logger's priority is low enough, we can just keep it untouched. BTW, the gzip plugin doesn't do the gzip directly, it just controls the behavior of gzip. |
BTW, we are not expected to discuss the logging response body in an issue about the request body. It's off-topic. 😄 |
OK,thanks bro~ |
@spacewander can I give this a try? |
I'm already submit a PR😁 #5501 |
you can can try to fix other issues: https://github.com/apache/apisix/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
Issue description
Add a request_body switch to the schema, and each body can be used by expr to decide whether to log or not. Without this switch, the body is not logged.
expr
can be evaluated by lua-resty-expr. request body can be fetched by core.request.get_body.Environment
apisix version
): 2.10.1uname -a
):nginx -V
oropenresty -V
):curl http://127.0.0.1:9090/v1/server_info
to get the info from server-info API):luarocks --version
):The text was updated successfully, but these errors were encountered: