An enterprise operates a critical e-commerce platform on Amazon EC2 instances managed by an Auto Scaling group in a production AWS account. The application writes transaction and system logs to `/var/log/app/service.log`. These logs undergo hourly rotation, where the active log file is renamed to `/var/log/app/service.log.YYYY-MM-DD-HH` and a new empty log file is created. The company wants to implement a near real-time monitoring and centralization solution. They need to monitor these logs in CloudWatch Logs for real-time error rate alerting and also store the logs in a centralized Amazon S3 bucket located in a separate security AWS account for long-term audit compliance. Which two configurations should a solutions architect implement to meet these requirements?
- Install the CloudWatch agent on the EC2 instances. Configure the agent configuration file with the `file_path` parameter set to `/var/log/app/service.log*` to ensure that both the active log file and any rotated files are continuously monitored and sent to CloudWatch Logs.Answer
- BInstall the CloudWatch agent on the EC2 instances. Configure the agent configuration file with the `file_path` parameter set to the static path `/var/log/app/service.log` to track the active log file, relying on the agent to automatically follow the file descriptor across hourly rotations.
- In the security account, configure the S3 bucket policy to grant `s3:PutObject` and `s3:PutObjectAcl` permissions to the specific IAM role ARN used by the Kinesis Data Firehose delivery stream in the production account. In the production account, configure a CloudWatch Logs subscription filter to stream the log group to Kinesis Data Firehose, which delivers them to the security account's S3 bucket.Answer
- DIn the security account, configure the S3 bucket policy to grant `s3:PutObject` permissions to the `logs.amazonaws.com` service principal, and configure a CloudWatch Logs subscription filter in the production account to stream logs directly to the security account's S3 bucket.
- EIn the production account, configure the CloudWatch agent to write logs directly to the security account's S3 bucket by configuring the `s3_delivery` block in the agent's configuration file, and attach a Service Control Policy (SCP) to the production account that grants `s3:PutObject` access to the security account's S3 bucket.