Cloud concept · Updated

Log Retention - Log retention is the policy and practice of keeping log records available for a defined period before securely deleting them.

In short

Log retention determines how long operational, security, and audit records remain available for monitoring, investigation, and compliance. An effective policy balances required history and retrieval speed against storage cost, privacy obligations, and protection from unauthorized alteration or deletion.

Cloud Concepts Hub →

6 key aspects of Log Retention

Effective log retention combines complete collection, justified preservation periods, appropriate retrieval performance, deletion protection, and verifiable expiration.

01
Requirements-based retention periods

Set durations by log category using investigation needs, applicable obligations, and privacy constraints. Document both minimum preservation requirements and any required deletion deadlines.

02
Source coverage and delivery continuity

Identify the administrative, identity, network, application, and data-access events needed for each workload. Verify collection scope and monitor delivery failures so that a retention policy does not conceal missing evidence.

03
Searchable and archival retention

Separate the period requiring immediate queries from the total preservation period. Choose storage tiers according to investigation response times, retrieval costs, and restore delays.

04
Protection against premature deletion

Use least-privilege access, separation of duties, and immutable storage where required. Retention settings alone do not necessarily prevent administrators or compromised credentials from deleting logs.

05
Controlled expiration and exceptions

Automate expiration while accounting for replicas, exports, and noncurrent object versions. Apply approved legal holds when necessary and understand which timestamp starts each retention clock.

06
Operational validation

Monitor policy changes, ingestion gaps, and storage growth, and regularly test historical queries or restores. Preserve access to encryption keys and decoding information throughout the required retention period.

Cloud services for Log Retention

CloudTrail supplies AWS activity records, while CloudWatch Logs collects supported workload and platform logs for operational monitoring. S3 can hold a centralized archive with lifecycle rules and, where required, Object Lock protection. OpenSearch Service can provide an indexed investigation window, while Athena supports queries over accessible S3 log data without maintaining a separate search index. Coordinate retention independently across these stores: deleting an index need not delete the archive, and expiring archive objects does not remove exported copies. Validate delivery, encryption-key access, query performance, and restoration procedures against the required investigation timeline.

Amazon S3Amazon S3

Amazon S3 provides durable storage for centralized log archives, with lifecycle rules for storage-class transitions and expiration. S3 Object Lock can protect object versions using retention periods or legal holds; lifecycle policies must also account for noncurrent versions when deletion is required.

AWS CloudTrailAWS CloudTrail

CloudTrail records AWS account activity, with trails delivering configured events to S3 for retention governed by the destination's policies. Its built-in event history covers 90 days of regional management events and does not replace a configured long-term archive or the explicit collection of required data events.

Amazon OpenSearch ServiceAmazon OpenSearch Service

OpenSearch Service supports indexed log analysis when engineers need interactive searches across retained events. Index State Management can automate index transitions and deletion, but indexed retention must be coordinated with any separate archive policy.

Amazon AthenaAmazon Athena

Athena queries logs stored in S3 without requiring a continuously running search cluster. It does not determine source-log retention; query availability depends on the underlying objects remaining accessible, including restoring archived objects when necessary.

Log Retention exam questions

Real practice exam questions on Log Retention, with the correct answer and its explanation. Answer them with every option in the exam simulator.

MLA-C02 (beta)

A company uses an AWS CloudTrail trail to deliver audit logs for its Amazon SageMaker AI workloads to Amazon S3. For newly delivered logs, a regulatory policy requires retention for seven years. During that period, no user, including the AWS account root user, may permanently delete the records or shorten their retention. Logs must remain immediately accessible for the first 90 days; afterward, retrieval within 48 hours is acceptable. Which configuration meets these requirements while reducing long-term storage costs?

Show answerCORRECT ANSWER

Enable S3 Object Lock on the destination bucket with a default seven-year retention period in compliance mode. Use an S3 Lifecycle rule to transition log objects to S3 Glacier Deep Archive after 90 days.

Object Lock compliance mode prevents permanent deletion of protected object versions or shortening of their retention, including by the root user. Lifecycle transitions preserve Object Lock protection. Keeping logs in an immediately accessible storage class initially and transitioning them to Glacier Deep Archive after 90 days reduces archival costs while supporting the allowed retrieval window.

SAP-C03

A company uses Amazon Security Lake to collect security logs from its AWS Organizations member accounts in three AWS Regions. Two Regions replicate their collected data to a designated rollup Region. Investigators query the consolidated data in the rollup Region. No storage-class transitions or expiration settings are currently configured.

The company's retention policy requires source-Region copies to expire after 30 days and consolidated copies in the rollup Region to remain available for 400 days. Investigators must be able to query the most recent 30 days of consolidated records without restoring objects. Older consolidated records can require a restore operation that takes several hours. The company wants to reduce storage costs by archiving older consolidated records.

Which configuration meets these requirements?

Show answerCORRECT ANSWER

Configure a 30-day expiration in each source Region. In the rollup Region, configure a transition to S3 Glacier Flexible Retrieval after 30 days and expiration after 400 days.

Security Lake lifecycle settings are regional. The source Regions can expire their copies after 30 days while the rollup Region retains its independently managed copies for 400 days. Transitioning consolidated objects to S3 Glacier Flexible Retrieval after 30 days preserves immediate query access to recent records and provides lower-cost archival storage for older records that can tolerate restoration.

SOA-C03

A company has an AWS CloudTrail trail that delivers management events to both an Amazon S3 bucket and a dedicated Amazon CloudWatch Logs log group. An existing S3 Lifecycle rule expires the archived log objects after 365 days. The log group currently retains events indefinitely.

The company requires recent events to remain searchable in CloudWatch Logs Insights for 30 days, after which they must expire automatically from CloudWatch Logs. The 365-day S3 archive must remain unchanged, and the trail must continue delivering events to both destinations.

Which change should a CloudOps engineer make?

Show answerCORRECT ANSWER

Set the CloudWatch Logs log group's retention period to 30 days and leave the S3 Lifecycle rule unchanged.

CloudWatch Logs retention is configured independently for each log group. A 30-day retention policy makes older events eligible for automatic deletion without changing CloudTrail delivery or the S3 archive's 365-day lifecycle.

Practice Log Retention in a full exam

Questions on Log Retention in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Log Retention

3 min read

Log retention defines how long log records must remain available and under what conditions they can be deleted. It is separate from log collection: enabling a log source does not guarantee that its records will be stored for the required duration. A complete design specifies the sources, collection scope, storage destinations, retention periods, retrieval expectations, and controls that preserve the records.

Start with workload and security requirements rather than choosing one duration for every log. Administrative API activity, authentication events, network flows, application errors, database audit events, and web access logs answer different investigative questions. Determine which events are needed to detect threats, reconstruct an incident, satisfy contractual obligations, or troubleshoot failures. Confirm whether each source must be explicitly enabled, whether collection covers all relevant accounts and Regions, and whether filtering or sampling could remove required evidence.

Retention periods should reflect the time between an event occurring and someone needing to investigate it. A workload with delayed fraud discovery may need substantially more history than a short-lived development environment. Define both the total retention period and the period during which logs must be immediately searchable. For example, an organization might require 30 days of interactive investigation data and one year of durable archived records. These are example requirements, not universal compliance defaults.

Cloud implementations commonly separate a searchable store from a lower-cost archive. Recent logs support dashboards, alerting, and incident queries, while older records move to storage with lower ongoing costs. The trade-offs include indexing expense, query charges, archive minimum storage durations, retrieval charges, and restore delays. A storage class that requires hours to restore data is inappropriate when investigators must search the full retained history within minutes. Verify that the archive preserves the fields, timestamps, and context needed to reconstruct events.

Retention must work across the entire delivery path. Buffer expiration, failed delivery, missing permissions, or encryption-key problems can create gaps before data reaches its final destination. Monitor ingestion failures, unexpected drops in volume, and changes to retention settings. Test retrieval of older records and retain the necessary decryption keys for as long as the encrypted logs must remain readable. Check whether each system calculates expiration from event time, ingestion time, or object creation time; late-arriving records can otherwise receive less usable retention than intended.

Retention is not the same as immutability or backup. A configured expiration period does not necessarily prevent a privileged user from deleting records early. Where evidence preservation requires stronger protection, combine access separation with immutable storage or legal holds. In versioned object storage, lifecycle rules must also address noncurrent versions when actual removal is required. Legal holds may suspend normal expiration, while privacy requirements may limit unnecessary retention of personal information.

Do not assume that longer retention automatically improves monitoring. Alerts depend on timely ingestion, appropriate event coverage, and effective detection logic; archived records mainly extend retrospective analysis. Likewise, a service's built-in event history is not automatically a long-term archive. On AWS, CloudTrail event history provides the previous 90 days of management events in each Region; longer retention requires a separately configured destination or event data store with suitable retention settings.

Learn Log Retention in lessons

9 short lessons on Log Retention in 7 certification courses.

and 3 more lessons

Open the lessons