[#11171] improvement(core): add JSON formatter for audit logs#11343
Open
freesinger wants to merge 1 commit into
Open
[#11171] improvement(core): add JSON formatter for audit logs#11343freesinger wants to merge 1 commit into
freesinger wants to merge 1 commit into
Conversation
jerryshao
reviewed
Jun 2, 2026
jerryshao
reviewed
Jun 2, 2026
7f2b263 to
4fa3164
Compare
4fa3164 to
4edfe00
Compare
Code Coverage Report
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch the default audit formatter to structured JSON so SIEM consumers can parse audit events reliably, while preserving compatibility through the existing formatter configuration. Also add coverage for JSON serialization, redaction, and default formatter wiring.
What changes were proposed in this pull request?
This PR adds a structured JSON formatter for audit logs and switches it to be the default audit formatter.
The main changes are:
JsonAuditFormatterto serialize each audit log entry as one JSON object per line.customInfo.timestampin ISO 8601 with millisecond precision and an explicit timezone offset.AuthorizationCookieX-Amz-Security-Tokens3.access-key-idjdbc-passwordresultCountas a top-level JSON field forListEventwhen the count is available.SimpleFormatterV2toJsonAuditFormatterthrough the existing formatter configuration.Why are the changes needed?
The existing audit formatters mainly emit tab-separated text, which is harder for SIEM systems and other downstream log processors to consume reliably.
This change is needed because:
AuditLog.customInfo()should be preserved in a structured way instead of being difficult to parse downstream.gravitino.audit.formatter.classNameif they need legacy behavior.Fix: #11171
Does this PR introduce any user-facing change?
Yes.
gravitino.audit.formatter.classNameis noworg.apache.gravitino.audit.JsonAuditFormatter.customInfoas structured JSON content instead of relying on TSV-compatible string formatting.How was this patch tested?
The patch was tested with targeted unit tests covering the new formatter and the default formatter wiring.
Executed test command:
The tests cover:
ListEventresultCountserialization.AuditLogManager.