An application runs on EC2 instances behind an Application Load Balancer in an Auto Scaling group. Because the application scales out and in frequently, instance logs disappear after scale-in. How can the development team retain and view application logs after instances are terminated by scale-in events?
Choose an answer
Tap an option to check your answer.
Correct answer: Configure the EC2 instances to publish application logs to Amazon CloudWatch Logs using the unified CloudWatch agent..
Why this is the answer
The correct solution is to configure EC2 instances to publish application logs to Amazon CloudWatch Logs using the unified CloudWatch agent. This ensures that logs are streamed off the instance in real time or near real time to a persistent, centralized logging service. Even if an instance is terminated during a scale-in event, its logs remain accessible in CloudWatch Logs, allowing the development team to view and analyze them. Enabling access logging on the Application Load Balancer only captures ALB access logs, not application-specific logs from the EC2 instances. Changing the Auto Scaling group to use a step scaling policy affects how scaling occurs, but it does not address the problem of ephemeral logs on terminated instances. Instrumenting the application with AWS X-Ray is for distributed tracing and performance analysis, not for collecting and retaining application logs.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed