Monitoring and troubleshooting pipelines
DEA-C01 · Lesson 17 of 23 · 2:21:05
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.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the DEA-C01 exam (AWS Certified Data Engineer – Associate). In this lesson: AWS CloudTrail event history, trails, and data events, CloudWatch Logs log groups, retention, and log classes, metric filters, alarms, and SNS notifications, subscription filters, log analysis with CloudWatch Logs Insights, Athena, OpenSearch Service, and EMR, and fixing failed or slow AWS Glue jobs with job run insights, grouping, the Spark UI, and auto scaling. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
A failure nobody saw
At three in the morning, the nightly Glue job at AnyCompany Games fails, and nobody notices until the product team finds an empty dashboard. The same week, the security team asks who changed a bucket policy, and finance asks why years of debug logs are still stored. This lesson covers auditing with CloudTrail, logging and alarms with CloudWatch, analyzing logs, and troubleshooting Glue and EMR.
Auditing with CloudTrail
AWS CloudTrail captures the actions of users, roles, and AWS services as events, whether they come from the console, the CLI, or the SDKs and APIs. The event history shows the last ninety days of management events in each Region, with no setup, like who changed a bucket policy or deleted a Glue job. For longer audits, a trail delivers events to an S3 bucket, with optional delivery to CloudWatch Logs and EventBridge, and it can cover every account of an organization. Data events, like reads and deletes of objects in S3, are high volume, so trails do not log them by default: you add them for the buckets that matter. Athena then queries the trail files in S3 with SQL, and Insights events flag unusual rates of API calls or errors.
CloudWatch Logs and alarms
Amazon CloudWatch Logs is the central logging service: Lambda functions and Glue jobs write their logs to log groups, which share the same retention, monitoring, and access settings. By default, log data is kept indefinitely, so set a retention period on each log group, ideally in your infrastructure as code, or an account-level retention policy for all log groups whose names share a prefix. Choose the Standard log class for logs that feed metric filters or subscriptions, and the Essentials class, formerly Infrequent Access, for logs that you only query after the fact. A metric filter turns matching log lines, like each error, into a CloudWatch metric, and an alarm on that metric sends a notification to an SNS topic when it crosses a threshold. A subscription filter streams log events in near real time to Kinesis, Firehose, Lambda, or OpenSearch Service, for processing or alerting.
Analyzing logs
CloudWatch Logs Insights queries log groups interactively, with its own query language, or with OpenSearch PPL or SQL, and it discovers fields automatically in logs from Lambda, CloudTrail, VPC, and JSON logs. Field indexes make large queries faster and cheaper, and scheduled queries can deliver their results to S3 or EventBridge. Athena queries logs stored in S3, like CloudTrail trail files or exported application logs, with standard SQL, and you pay per data scanned. Amazon OpenSearch Service is built for log analytics and real-time application monitoring, and a subscription filter can stream CloudWatch logs to it in near real time. And for very large volumes of big data application logs in S3, like Spark and Hadoop logs, an EMR cluster can process them with Spark or Hive.
Troubleshooting Glue and EMR
To troubleshoot a Glue job, start with its logs in CloudWatch Logs, and turn on job run insights, which add the failing line of the script, the root cause, and a recommended action. When the driver runs out of memory while it reads millions of small files, turn on grouping, so each task reads a group of files rather than one file. When an executor runs out of memory while it reads a large JDBC table, use Glue dynamic frames, which fetch one thousand rows at a time, or set a fetch size. For performance, the Spark UI shows the slow stages, auto scaling adds and removes workers as each stage needs them, and a timeout stops a job that hangs. On EMR, logs are written to the primary node and, if you configure it, archived to S3, with step logs and application logs, and managed scaling resizes the cluster with the load.
Monitoring at AnyCompany Games
Here is the setup at AnyCompany Games: an organization trail delivers management events to S3, with S3 data events on the buckets of player data, and Athena queries the trail for audits. Every log group keeps its logs for ninety days, a setting written in the infrastructure code, and debug logs use the Essentials class. A metric filter counts errors in the Glue logs, and an alarm sends a notification to the SNS topic of the on-call engineer, for full traceability of each failure. And job run insights are on for every Glue job, which made the small files problem easy to find, and to fix with grouping.
Recap
Let's recap. CloudTrail captures API calls: ninety days of event history, trails to S3 for longer audits, and data events added where they matter. CloudWatch Logs keeps logs in log groups: set their retention, and pick the Standard or Essentials class. Metric filters and alarms send notifications through SNS, and subscription filters stream logs in near real time. Logs Insights, Athena, OpenSearch Service, and EMR analyze logs, from quick searches to huge volumes. And for Glue, job run insights, grouping, dynamic frames, the Spark UI, and auto scaling solve most failures and slow jobs.
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.
The security team wants a log of every object read and deleted in the S3 bucket of player data, from now on, for audits. The organization trail captures only management events. What should the data engineer add?
- A CloudWatch alarm on the number of objects in the bucket
- Access to the 90-day CloudTrail event history
- Glue job run insights on the jobs that read the bucket
- S3 data events on the trail, for that bucket
Show the answer
S3 data events on the trail, for that bucket
Data events capture actions on objects, like reads and deletes, and trails do not log them by default. “A CloudWatch alarm on the number of objects in the bucket” would count objects, without saying who read or deleted them. “Access to the 90-day CloudTrail event history” would show management events only, for ninety days. And “Glue job run insights on the jobs that read the bucket” would explain Glue failures, not who reads the bucket.
A Glue job that reads two million small JSON files from S3 fails because the driver runs out of memory, while the executors use almost no memory. What should the data engineer do?
- Add more workers so that the executors have more memory
- Turn on grouping, so each task reads a group of files
- Raise the job timeout to the maximum value allowed
- Rewrite the job as a Python shell job on one worker
Show the answer
Turn on grouping, so each task reads a group of files
Grouping lets each task read a group of files, so the driver tracks far fewer tasks, and uses less memory. “Add more workers so that the executors have more memory” would add executors, but the executors are not the problem. “Raise the job timeout to the maximum value allowed” would let the job run longer, but it fails on memory, not on time. And “Rewrite the job as a Python shell job on one worker” would give the job less capacity, without Spark.
Application logs from 40 Lambda functions go to CloudWatch Logs. During an incident, the team wants the ten most frequent error messages of the last hour, in seconds, without moving or copying any data. What should the data engineer use?
- An export of the log groups to S3, then Athena queries
- CloudTrail data events on the Lambda functions
- A CloudWatch Logs Insights query on the log groups
- A new OpenSearch Service domain with a subscription
Show the answer
A CloudWatch Logs Insights query on the log groups
Logs Insights queries the log groups where they are, and returns the most frequent errors in seconds. “An export of the log groups to S3, then Athena queries” would copy the logs to S3 first, which takes time. “CloudTrail data events on the Lambda functions” would capture calls to the functions, not the messages that they write. And “A new OpenSearch Service domain with a subscription” would need a new domain, and would copy the logs to it.