Discover how to retain application logs from EC2 instances in an Auto Scaling group, even after they are terminated during scale-in events, using Amazon CloudWatch Logs and the unified CloudWatch agent.
Table of Contents
Question
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?
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.
Answer
B. Configure the EC2 instances to publish logs to Amazon CloudWatch Logs by using the unified CloudWatch agent.
Explanation
CloudWatch Logs is a log management service that allows you to centralize and store logs from various sources, including EC2 instances. By configuring the EC2 instances to publish logs to CloudWatch Logs using the unified CloudWatch agent, you can retain the logs even after instances are terminated during a scale-in event.
Here’s a detailed explanation:
- The unified CloudWatch agent is a software component that can be installed on EC2 instances to collect and send logs to CloudWatch Logs.
- When the agent is installed and configured on the instances, it will automatically stream the application logs to CloudWatch Logs in real-time.
- CloudWatch Logs stores the log data indefinitely, allowing you to access logs from terminated instances even after they have been scaled in.
- The development team can then use the CloudWatch Logs console, API, or integration with other AWS services like Amazon Athena or Amazon QuickSight to analyze and query the logs for performance optimization.
A. Enabling access logs for the ALB and storing them in an Amazon S3 bucket will capture the logs related to the load balancer itself, but not the application logs from the EC2 instances.
C. Modifying the Auto Scaling group to use a step scaling policy will not solve the issue of retaining application logs after instances are terminated during a scale-in event.
D. Instrumenting the application with AWS X-Ray tracing will provide visibility into the application’s performance and trace data, but it does not directly address the issue of retaining application logs after instances are terminated.
Amazon AWS Certified Solutions Architect – Professional SAP-C02 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Amazon AWS Certified Solutions Architect – Professional SAP-C02 exam and earn Amazon AWS Certified Solutions Architect – Professional SAP-C02 certification.