Files
kong-catalog-api/kong/rest/audit-log-body-capture.yaml
T
Stéphane Tailland 95f9b611b3 Capture request/response bodies for audit-log via pre/post-function
Body capture lives in dedicated audit-log-body-capture(-bindings).yaml
files, separate from audit-log.yaml itself, so they can be dropped
without touching the base logging plugin (degrades gracefully to
metadata-only via nil custom_fields). Response body captured in
body_filter (chunk-accumulated) rather than the log phase, which
cannot call kong.response.get_raw_body() directly.
2026-08-21 14:53:52 +02:00

28 lines
912 B
YAML

# dev only: captures raw request/response bodies into kong.ctx.shared for
# audit-log.yaml's custom_fields_by_lua to read back in the log phase.
# Drop this file (and its bindings) to stop body capture without touching
# audit-log.yaml itself — it degrades gracefully to metadata-only logging.
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-catalog-api-audit-capture-request
namespace: ${NAMESPACE}
plugin: pre-function
config:
access:
- "kong.ctx.shared.audit_request_body = kong.request.get_raw_body()"
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-catalog-api-audit-capture-response
namespace: ${NAMESPACE}
plugin: post-function
config:
body_filter:
- |
local chunk = ngx.arg[1]
if chunk then
kong.ctx.shared.audit_response_body = (kong.ctx.shared.audit_response_body or "") .. chunk
end