From 2a56f35e41e4bf9865d6b23fbe583b871494b652 Mon Sep 17 00:00:00 2001 From: MariaLapovska Date: Tue, 18 Mar 2025 20:32:58 -0500 Subject: [PATCH] Add max request and response body bytes attributes to http-logger plugin --- apisix/plugins/http-logger.lua | 2 ++ docs/en/latest/plugins/http-logger.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apisix/plugins/http-logger.lua b/apisix/plugins/http-logger.lua index 44f84acc907d..244c2bb72d9d 100644 --- a/apisix/plugins/http-logger.lua +++ b/apisix/plugins/http-logger.lua @@ -50,6 +50,8 @@ local schema = { type = "array" } }, + max_req_body_bytes = {type = "integer", minimum = 1, default = 524288}, + max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288}, concat_method = {type = "string", default = "json", enum = {"json", "new_line"}}, ssl_verify = {type = "boolean", default = false}, diff --git a/docs/en/latest/plugins/http-logger.md b/docs/en/latest/plugins/http-logger.md index d07375b0bcea..d7ae6f478c77 100644 --- a/docs/en/latest/plugins/http-logger.md +++ b/docs/en/latest/plugins/http-logger.md @@ -43,8 +43,10 @@ This will allow the ability to send log data requests as JSON objects to monitor | log_format | object | False | | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. | | include_req_body | boolean | False | false | [false, true] | When set to `true` includes the request body in the log. If the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitations. | | include_req_body_expr | array | False | | | Filter for when the `include_req_body` attribute is set to `true`. Request body is only logged when the expression set here evaluates to `true`. See [lua-resty-expr](https://github.com/api7/lua-resty-expr) for more. | +| max_req_body_bytes | integer | False | 524288 | >=1 | Maximum request body allowed in bytes. Request bodies falling within this limit will be pushed to server. If the size exceeds the configured value, the body will be truncated before being pushed to server. | | include_resp_body | boolean | False | false | [false, true] | When set to `true` includes the response body in the log. | | include_resp_body_expr | array | False | | | When the `include_resp_body` attribute is set to `true`, use this to filter based on [lua-resty-expr](https://github.com/api7/lua-resty-expr). If present, only logs the response if the expression evaluates to `true`. | +| max_resp_body_bytes | integer | False | 524288 | >=1 | Maximum response body allowed in bytes. Response bodies falling within this limit will be pushed to server. If the size exceeds the configured value, the body will be truncated before being pushed to server. | | concat_method | string | False | "json" | ["json", "new_line"] | Sets how to concatenate logs. When set to `json`, uses `json.encode` for all pending logs and when set to `new_line`, also uses `json.encode` but uses the newline (`\n`) to concatenate lines. | | ssl_verify | boolean | False | false | [false, true] | When set to `true` verifies the SSL certificate. |