An energy management company operates a critical power-grid monitoring application on a fleet of Amazon EC2 instances across multiple AWS accounts managed by AWS Organizations. The application logs are written to `/opt/app/logs/grid-metrics.log` and are rotated hourly by a custom script into the same directory as `/opt/app/logs/grid-metrics-YYYY-MM-DD-HH.log`. After 24 hours, the rotated logs are compressed to `/opt/app/logs/grid-metrics-YYYY-MM-DD-HH.log.gz`. The company needs to centralize these logs into an Amazon S3 bucket in a dedicated security account with minimal latency, ensuring no logs are lost during rotation, and compressed files are not duplicated or corrupted during ingestion. Which configuration strategy achieves this with the highest operational efficiency and least administrative overhead?
- Install the CloudWatch agent on the EC2 instances, and configure the file path `/opt/app/logs/grid-metrics*.log` to collect active and uncompressed rotated logs. In the central security account, create an Amazon Kinesis Data Firehose delivery stream pointing to the destination Amazon S3 bucket, and establish a CloudWatch Logs destination with an access policy that allows the source accounts to write to it. In the source accounts, configure CloudWatch Logs subscription filters to forward the collected log events to the central destination.Answer
- BInstall the CloudWatch agent on the EC2 instances, and configure the file path `/opt/app/logs/grid-metrics.log`. Set up an hourly cron job on each EC2 instance that uses the AWS CLI to upload any rotated files matching the pattern `/opt/app/logs/grid-metrics-*.log` to the centralized Amazon S3 bucket. Restrict the S3 bucket policy in the security account to trust only the IAM roles of the source EC2 instances.
- CInstall the CloudWatch agent on the EC2 instances, and configure the file path `/opt/app/logs/grid-metrics*` to ensure all generated log files are captured. Configure the S3 bucket policy in the central security account to permit the root principal of the source accounts to write directly to the bucket. In the source accounts, configure the CloudWatch agent to write log files directly to the central S3 bucket using cross-account IAM roles.
- DInstall the CloudWatch agent on the EC2 instances, and configure the file path `/opt/app/logs/grid-metrics-*.log`. Configure an AWS Lambda function in the central security account that is triggered hourly to invoke AWS Systems Manager Run Command across the source EC2 instances to retrieve the active `/opt/app/logs/grid-metrics.log` content, writing the consolidated output directly to the destination Amazon S3 bucket.