Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
AWS · DEA-C01

Logs for audit

DEA-C01 · Lesson 22 of 23 · 3:11:49

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the DEA-C01 exam (AWS Certified Data Engineer – Associate). In this lesson: CloudTrail event history and trails for one account or a whole organization, log file integrity validation, CloudWatch Logs retention, data protection policies, subscriptions, and centralization, CloudTrail Lake (closed to new customers) and querying trails with Athena, and log analysis with Logs Insights, OpenSearch Service, and EMR. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Who deleted the table?

An auditor asks AnyCompany Games to prove who deleted a table last spring, and to show that the logs were never changed. Application logs contain player email addresses, and each team searches its own account by hand. This lesson covers trails for audit, application logs, CloudTrail Lake, and log analysis at scale.

Trails for audit

CloudTrail tracks API calls from the console, the CLI, the SDKs, and AWS services, and event history keeps the last ninety days of management events in each Region. For audit, create a trail, which delivers log files to an S3 bucket for as long as you keep them, and an organization trail does this for every account of an organization. Trails log management events by default, while data events, like reads and writes of S3 objects, must be turned on, because they are high in volume. Log file integrity validation adds a digest file every hour, with a hash of each log file and a digital signature, so you can prove that a log file was not changed or deleted after delivery. Store the trail in a bucket with tight access, ideally in a dedicated logging account, so the people you audit cannot erase their tracks.

Application logs in CloudWatch Logs

Application logs, like the output of Lambda functions, Glue jobs, and your own code, belong in CloudWatch Logs, in log groups. Log data is kept forever by default, so set a retention period that matches your audit rules. When logs might contain personal data, a data protection policy on the log group masks it wherever it leaves, including Logs Insights and subscription filters. Only users with the unmask permission of CloudWatch Logs can view the original values. To audit many accounts in one place, subscriptions send log events to Kinesis, Firehose, or Lambda, and centralization copies log data from several accounts and Regions into a central account.

CloudTrail Lake

CloudTrail Lake runs SQL queries on events, which it keeps in event data stores, immutable collections of events. An event data store can hold CloudTrail events, Insights events, and AWS Config configuration items, and an organization event data store gathers events from every account and Region of an organization. Events can be kept for up to about seven or ten years, depending on the retention option, and queries can join several event data stores. You can also federate an event data store into the Glue Data Catalog, and query it with Athena. Note that CloudTrail Lake has been closed to new customers since the end of May 2026: existing customers can continue to use it, while new ones query trails in S3 with Athena.

Analyzing logs at scale

For trail files in S3, Athena queries them through a table, which you can create from the CloudTrail console, with partition projection to read only the dates and Regions that you need. For logs in CloudWatch Logs, Logs Insights runs interactive queries on one or more log groups, with fields discovered automatically for CloudTrail, Lambda, and JSON logs. OpenSearch Service suits full-text search and dashboards on logs, and OpenSearch Ingestion is a serverless collector that streams and transforms logs into a domain or a collection. For very large volumes of logs, like billions of game server lines each day, EMR processes them with Spark or Hive, on a cluster that scales. So pick the tool by the question: SQL on trail files, quick searches in CloudWatch Logs, search and dashboards, or heavy processing.

Audit at AnyCompany Games

Here is the setup at AnyCompany Games: an organization trail delivers log files, with integrity validation, to a bucket in a dedicated logging account. Lambda and Glue logs go to CloudWatch Logs with a one-year retention, and a data protection policy masks email addresses. The security team queries an organization event data store in CloudTrail Lake, which the company has used since 2025. And game server logs, billions of lines a day, are processed by EMR, while OpenSearch dashboards show the latest errors.

Recap

Let's recap. CloudTrail tracks API calls: event history covers ninety days, and trails keep log files in S3, for one account or a whole organization. Integrity validation proves that log files were not changed or deleted. CloudWatch Logs stores application logs, with retention, data protection policies, subscriptions, and centralization. CloudTrail Lake runs SQL on event data stores, and it is closed to new customers, who query trails with Athena. And Logs Insights, OpenSearch, and EMR analyze logs, from quick searches to very large volumes.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. Auditors want proof that the CloudTrail log files in S3 were not changed or deleted after CloudTrail delivered them. What should the data engineer turn on?

    • Log file integrity validation on the trail
    • Data events for the S3 bucket that stores the logs
    • A data protection policy on a CloudWatch log group
    • An event history search of the last ninety days
    Show the answer

    Log file integrity validation on the trail

    Integrity validation adds a digest file each hour, signed by CloudTrail, so changed or deleted log files can be detected. “Data events for the S3 bucket that stores the logs” would log reads and writes of the bucket, without proving that files are unchanged. “A data protection policy on a CloudWatch log group” would mask sensitive data in CloudWatch Logs. And “An event history search of the last ninety days” would only show ninety days of management events, with no proof about the files.

  2. A Lambda function writes player email addresses into its logs. The team wants them hidden in Logs Insights and in subscription filters, but a few investigators must still see them. What should the data engineer set up?

    • A shorter retention period on the log group
    • An organization trail with S3 data events
    • A data protection policy on the log group
    • A metric filter that counts email addresses
    Show the answer

    A data protection policy on the log group

    The policy masks matching data wherever it leaves the log group, and only users with the unmask permission see the original values. “A shorter retention period on the log group” would delete logs sooner, but the addresses would stay visible until then. “An organization trail with S3 data events” would log API calls, not the logs of the function. And “A metric filter that counts email addresses” would count matches, without hiding anything.

  3. AnyCompany Games has used CloudTrail Lake since 2025. The security team wants SQL queries on API activity from every account and Region of the organization, in one place, kept for seven years. What should the data engineer create?

    • A metric filter on CloudTrail logs in each account
    • An organization event data store in CloudTrail Lake
    • An event history search in each Region of each account
    • A trail in each account, delivering to its own bucket
    Show the answer

    An organization event data store in CloudTrail Lake

    An organization event data store gathers events from every account and Region, keeps them for years, and answers SQL queries. “A metric filter on CloudTrail logs in each account” would count matching events in each account, with no SQL queries in one place. “An event history search in each Region of each account” would cover only ninety days, one Region at a time. And “A trail in each account, delivering to its own bucket” would scatter log files across buckets, with no single place to query them.