AWS Certified Solutions Architect – Professional (SAP-C02) — Question 287
A company has an application that is deployed on Amazon EC2 instances behind an Application Load Balancer (ALB). The instances are part of an Auto Scaling group. The application has unpredictable workloads and frequently scales out and in. The company’s development team wants to analyze application logs to find ways to improve the application's performance. However, the logs are no longer available after instances scale in.
Which solution will give the development team the ability to view the application logs after a scale-in event?
Answer options
- A. Enable access logs for the ALB. Store the logs in an Amazon S3 bucket.
- B. Configure the EC2 instances to publish logs to Amazon CloudWatch Logs by using the unified CloudWatch agent.
- C. Modify the Auto Scaling group to use a step scaling policy.
- D. Instrument the application with AWS X-Ray tracing.
Correct answer: B
Explanation
Using the unified CloudWatch agent on the EC2 instances allows application logs to be continuously streamed to Amazon CloudWatch Logs, ensuring they are preserved even after the instances are terminated during a scale-in event. ALB access logs (Option A) only capture HTTP traffic metrics, not application-specific logs, while changing the scaling policy (Option C) does not address log retention. AWS X-Ray (Option D) is used for tracing request paths and latency analysis rather than aggregating and preserving application log files.