Fix audit events logged as INFO+2 instead of AUDIT#5256
Open
kimjune01 wants to merge 2 commits into
Open
Conversation
Audit events were logging as "INFO+2" which breaks level detection in log aggregation systems (Loki, Elasticsearch, Splunk). This caused audit events to appear as unknown level and prevented level-based filtering in log pipelines. Changed NewAuditLogger to add a ReplaceAttr function that renders the custom audit level (slog.Level(2)) as "AUDIT" string in JSON output, while preserving the numeric level for internal filtering. Preserves the original design intent of placing audit between INFO and WARN, while making events filterable via level="AUDIT" in LogQL and other query languages. Fixes stacklok#4296 Signed-off-by: June Kim <kim.june.01@gmail.com> Signed-off-by: June Kim <kimjune01@gmail.com>
Internal pipeline metadata should not be committed to the upstream repo.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5256 +/- ##
==========================================
+ Coverage 67.99% 68.05% +0.05%
==========================================
Files 616 616
Lines 63005 63008 +3
==========================================
+ Hits 42840 42878 +38
+ Misses 16963 16928 -35
Partials 3202 3202 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
ReplaceAttrto the audit logger's JSON handler so the custom audit level renders as"AUDIT"instead of"INFO+2"Test plan
"AUDIT", another verifying standard levels (INFO, WARN) are preservedgo test ./pkg/audit/... -count=1: 28 tests passed