Add new setting to control splitting log4j audit messages to prevent audit_trace_indices/audit_trace_resolved_indices from making messages too big#5977
Open
parislarkins wants to merge 3 commits intoopensearch-project:mainfrom
Conversation
…racters_per_message, when non-zero split audit log messages audit_trace_indices and audit_trace_resolved_indices into multiple messages that are under the maximum Signed-off-by: Paris Larkins <paris.larkins@netapp.com>
108994e to
b338b23
Compare
Signed-off-by: Paris Larkins <paris.larkins@netapp.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5977 +/- ##
==========================================
- Coverage 73.87% 73.83% -0.04%
==========================================
Files 439 439
Lines 27086 27132 +46
Branches 4018 4024 +6
==========================================
+ Hits 20009 20034 +25
- Misses 5171 5190 +19
- Partials 1906 1908 +2
🚀 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.
Add new setting
plugins.security.audit.config.log4j.maximum_index_characters_per_message, when non-zero split audit log messages audit_trace_indices and audit_trace_resolved_indices into multiple messages that are under the maximum limit.Description
Enhancement/New feature?
For clusters with large numbers of indices (e.g. ~11,000 in the case I first observed this issue) with the
plugins.security.audit.config.resolve_indicesOpenSearch setting andappender.rolling_audit.layout.maxMessageLength=0log4j setting enabled (to disable log message truncation), theaudit_trace_indicesandaudit_trace_resolved_indicesfields in audit logs that relate to all indices can be extremely long. For example, 11,000 indexes with 100 character long names requires 1,100,000 characters to just to represent the index names alone (plus even more characters for the surrounding quotes and commas between each of them).These messages can get so large as to cause problems for downstream parts of your logging pipeline (for example, the default Apache Kafka maximum message is 1mb). In these cases, it is usually recommended to split large messages into smaller ones, as they are able to be handled more efficiently than giant messages.
Old behaviour
Log4j audit messages log an unlimited number of index names in the
audit_trace_indicesandaudit_trace_resolved_indicesfields, leading to giant log messages for clusters with lots of indexes.New behaviour
A simple example: If we set the new setting
plugins.security.audit.config.log4j.maximum_index_characters_per_messageto18, this original message:{ "audit_trace_indices": [ "index*" ], "audit_trace_resolved_indices": [ "index1", "index2", "index3", "index4", "index5", "index6", "index7", "index8" ], "audit_category": "AUTHENTICATED" }Would then be split into the following 3 messages:
{ "audit_trace_indices": [ "index*" ] "audit_trace_resolved_indices": [ "index2", "index3" ], "audit_category": "AUTHENTICATED" }{ "audit_trace_resolved_indices": [ "index4", "index5", "index6" ], "audit_category": "AUTHENTICATED" }{ "audit_trace_resolved_indices": [ "index7", "index8" ], "audit_category": "AUTHENTICATED" }These 3 split messages contain the exact same information as the source message, so no information is lost (although it is more effort to re-construct the original event).
Issues Resolved
#5976
Testing
Unit tests added to AuditMessageTest class.
I have been running my fork of the plugin using this setting on live clusters successfully to reduce the maximum size of audit log messages so they can fit in the 1mb maximum Apache Kafka message size in my logging pipeline.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.