Q4 — AWS DOP-C02 Ch.2
Question 4 of 100 | ← Chapter 2
A developer manages the company's Amazon Elastic Container Service (ECS) cluster. The cluster runs on several Amazon EC2 instances located in an Auto Scaling group. The developer wants to implement a solution that logs and reviews stopped tasks to identify errors.
- A. Create an Amazon EventBridge rule to capture task state changes. Send events to Amazon CloudWatch Logs. Use CloudWatch Logs Insights to investigate stopped tasks. ✓
- B. Configure tasks to write embedded metric format log data. Store these logs in Amazon CloudWatch Logs. Monitor container instance metrics for changes.
- C. Configure EC2 instances to store logs in Amazon CloudWatch Logs. Create a CloudWatch Contributor Insights rule using EC2 instance log data. Use the Contributor Insights rule to investigate stopped tasks.
- D. Configure EC2 Auto Scaling lifecycle hooks for EC2_INSTANCE_TERMINATING scale events. Write system event log files to Amazon S3. Use Amazon Athena to query log files for errors.
Correct Answer: A. Create an Amazon EventBridge rule to capture task state changes. Send events to Amazon CloudWatch Logs. Use CloudWatch Logs Insights to investigate stopped tasks.
Explanation
Amazon EventBridge can monitor and respond to ECS task state change events, forwarding related activity to Amazon CloudWatch Logs. CloudWatch Logs Insights enables querying and analysis of log data to effectively identify root causes of stopped tasks. Option B focuses on embedded metrics rather than detailed logs; option C's Contributor Insights identifies frequent log patterns but does not directly handle task state events; option D's Auto Scaling lifecycle hooks target EC2 instances—not ECS tasks. The combination of EventBridge and CloudWatch Logs directly fulfills the requirement to collect and analyze task stop events. Refer to AWS documentation on ECS event integration and log analysis.