Audit Log Retention and Rotation
What you'll learn: How to configure audit log rotation policies, size appropriately, maintain integrity, and prevent data loss during high-activity periods.
Why Audit Logs Need Management
Audit logs grow continuously as the system records security events. Without proper rotation and retention policies, you face three critical risks: disk exhaustion (causing system failures), performance degradation, and potential loss of critical forensic evidence. Think of it like a notebook that never runs out of pages—eventually it becomes too heavy to carry and impossible to search through.
Core Concepts
Rotation means closing the current log file and starting a fresh one based on triggers like size, time, or both. The auditd daemon handles this through /etc/audit/auditd.conf:
# Size-based rotation
max_log_file = 100 # MB before rotation
num_logs = 50 # Keep 50 rotated files
Retention determines how long old logs remain available. Compliance frameworks often mandate specific periods (e.g., 90 days, 1 year).
Sizing Considerations
Calculate expected audit volume based on:
- Number of audit rules active
- System activity levels (servers under heavy load generate more events)
- Event types being captured
Rule of thumb: provision 2-3x your calculated daily volume to handle activity spikes.
Preventing Data Loss
Configure the disk_full_action and disk_error_action parameters to control behavior when storage fills:
disk_full_action = SUSPEND # Halt auditing, not system
space_left_action = EMAIL # Alert when threshold reached
For critical systems, consider remote logging (covered in earlier lessons) as a safety net—logs stream to a centralized collector even if local storage fails.
Maintaining Integrity
Rotate logs without gaps using max_log_file_action = ROTATE and protect rotated files with permissions and checksums to detect tampering.
Key Takeaway: Proper audit log rotation balances disk space constraints with forensic requirements; configure size limits, retention counts, and low-space actions to prevent both data loss and system disruption during security investigations.