v3rpc: add lightweight request audit logging#21764
Conversation
Add a new flag to enable lightweight audit logging of all unary gRPC requests at warn level. Logs method, key, client IP, and duration without expensive proto serialization (proto.Size, .String). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: icoolchn <icoolchn@users.noreply.github.com>
Implement logLightweightRequestInfo that extracts only O(1) fields per request type (key, range_end, lease_id, etc.) without calling proto.Size() or .String(). When --experimental-log-request-info is enabled, every unary gRPC request is logged at warn level with method, key, client IP, and duration. PutRequest deliberately omits value to match existing redaction in NewLoggablePutRequest. Stream requests are out of scope. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: icoolchn <icoolchn@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: icoolchn The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @icoolchn. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Audit logging pipeline have totally different requirements and expected properties than normal logging. I would start from defining the differences and goals you want to achieve. |
I understand audit logging has different requirements than normal logging. Having defined the differences, I believe etcd's current need is not a full audit pipeline — it's a lightweight request logging path within the existing logging system. Definitions
Key distinction: Request Logging vs Audit Logging
Request logging focuses on "what happened", audit logging focuses on "can you prove it happened". This proposal is positioned as request logging, not audit logging. Why lightweight approachI looked at how other systems handle this:
Proposed approachFollowing ZooKeeper's pattern (reusing logback with isolated logger name), I propose reusing etcd's existing logging framework (zap) with a dedicated This follows the same pattern as PR #13236 ( Would you be open to this direction? I can update the PR accordingly, and add the full design document to the PR description if you'd like more details. |
I've updated my previous comment with a clearer breakdown of request logging vs audit logging, and why I believe the lightweight approach fits etcd's current needs. Would appreciate your thoughts. |
Summary
Add
--experimental-log-request-infoflag to enable lightweight audit logging of all unary gRPC requests at warn level. Logs method, key, client IP, andduration without expensive proto serialization (
proto.Size,.String()).This fills the gap between:
--log-level=debug: logs all requests but with heavy serialization, unsuitable for production--warning-unary-request-duration: only logs slow requestsKey Design
proto.Size()or.String()calls--log-level=info, won't flood Info-level logsNewLoggablePutRequestredaction)Test Plan
logLightweightRequestInfowith all request types