-
Notifications
You must be signed in to change notification settings - Fork 351
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
Filters: logBody("request", "response") #2282
Comments
I think there is |
I see. I used it and it seems the default when running skipper as library was 0 bytes. Will try again soon and close the issue if it works well. |
Skipper with Simulated backend application: $ ./bin/skipper -inline-routes='all: * -> inlineContent("<h1>response</h1>") -> <shunt>' -address=:9092 Request proxy: $ ./bin/skipper -inline-routes='all: * -> auditLog() -> "http://localhost:9092"' -max-audit-body=1024 Request: $ curl -v GET localhost:9090 -d 'a=b' Logs: $ ./bin/skipper -inline-routes='all: * -> auditLog() -> "http://localhost:9092"' -max-audit-body=1024
[APP]INFO[0000] Expose metrics in codahale format
[APP]INFO[0000] enable swarm: false
[APP]INFO[0000] Replacing lua filter specification
[APP]INFO[0000] support listener on :9911
[APP]INFO[0000] Dataclients are updated once, first load complete
[APP]INFO[0000] proxy listener on :9090
[APP]INFO[0000] TLS settings not found, defaulting to HTTP
[APP]INFO[0000] route settings, reset, route: all: * -> auditLog() -> "http://localhost:9092"
[APP]INFO[0000] route settings received
[APP]ERRO[0000] Failed to start supportListener on :9911: listen tcp :9911: bind: address already in use
[APP]INFO[0000] route settings applied
{"method":"POST","path":"/","status":200,"requestBody":"a=b"}
127.0.0.1 - - [25/Apr/2023:11:03:44 +0200] "POST / HTTP/1.1" 200 17 "-" "curl/7.81.0" 2 localhost:9090 - - So I'm looking to log the request body in the request filter and the response body in the response filter, just like the |
This is done like that because request body is read only after request path of filter chain during backend request. |
As it's an auditlog you want to have request and response in the same line or "object" logged, because action X resulted in Y. |
I want to try to implement it, if it's okay. |
oh, just noticed your comment @szuecs 😅 |
One idea for logging request/response body without buffering is to log it in chunks along with some kind of unique request/response id (memory address?) as soon as chunks are sent (i.e. intercept Body.Read and log what has been read). |
@AlexanderYastrebov do you mean
|
@szuecs Yes, this or maybe x-flow-id if present (and then document that it should be used like |
@AlexanderYastrebov this would be the same in request and response, but I guess this is even better I just pushed the change:
So chunks also work as expected |
Is your feature request related to a problem? Please describe.
I'd like to use skipper as proxy for APIs and log the request & response pairs, so that I can later mock the APIs.
Describe the solution you would like
Skipper already provides a filter logHeader to log request headers. Similarly, there could be a filter provided
logBody
that logs the request body/response (e.g. up to a certain size) (or a lua function that provides access to the request/response body).Describe alternatives you've considered (optional)
Additional context (optional)
Would you like to work on it?
No
The text was updated successfully, but these errors were encountered: