Question #788
A company runs a web application on Amazon EC2 instances behind an Application Load Balancer (ALB), with instances managed by an Auto Scaling group. The application experiences fluctuating traffic, leading to frequent scaling events. The operations team needs to debug intermittent errors but cannot access logs after instances terminate during scale-in events. Which solution ensures the logs remain available post-termination?
Enable ALB access logging and store logs in an Amazon S3 bucket.
Use the unified CloudWatch agent to stream logs from EC2 instances to Amazon CloudWatch Logs.
Update the Auto Scaling group to use target tracking scaling policies.
Integrate AWS X-Ray SDK into the application for detailed request tracing.
Explanation
Answer B is correct because the CloudWatch agent streams application logs from EC2 instances to CloudWatch Logs in real-time, ensuring logs are retained after instance termination. This directly addresses the issue of losing logs during scale-in.
Option A (ALB access logging) captures load balancer logs but not application-level logs. Option C (target tracking) optimizes scaling but does not solve log retention. Option D (X-Ray) focuses on request tracing, not log storage. Key points: CloudWatch Logs centralizes logs independent of instance lifecycle; Auto Scaling scale-in removes instances, so on-instance logs are lost unless streamed externally.
Answer
The correct answer is: B