An enterprise runs a batch processing application on hybrid on-premises servers and Amazon EC2 instances. The application writes execution logs to `/var/log/app/batch.log`. To comply with compliance and auditing policies, these logs are rotated hourly and renamed using the format `/var/log/app/batch.log.YYYY-MM-DD-HH`. A Solutions Architect is deploying the unified CloudWatch agent to collect these logs and publish them to Amazon CloudWatch Logs. Which configuration strategy for the CloudWatch agent should the Solutions Architect implement to ensure that logs are continuously collected without gaps during and after the hourly rotation process?
- ASpecify the static file path `/var/log/app/batch.log` in the `file_path` parameter of the agent configuration file and rely on the operating system file descriptor tracking to capture rotated log data.
- BConfigure the agent to write directly to an Amazon S3 bucket in a centralized security account, using an S3 bucket policy that permits public write access to simplify cross-account authentication.
- Use a wildcard pattern `/var/log/app/batch.log*` in the `file_path` parameter of the agent configuration file to ensure the agent monitors both the active and rotated files during the transition.Cevap
- DEnable log encryption using the AWS-managed KMS key for CloudWatch Logs (`aws/logs`) and configure the monitoring account's cross-account access by updating the policy of this AWS-managed key.
Cevap
Use a wildcard pattern `/var/log/app/batch.log*` in the `file_path` parameter of the agent configuration file to ensure the agent monitors both the active and rotated files during the transition.
Specifying a wildcard pattern `/var/log/app/batch.log*` in the `file_path` parameter of the CloudWatch agent configuration allows the agent to monitor both the active log file and any rotated files. This ensures that any log entries that remain in the buffer or are written during the rotation window are successfully captured and uploaded.
Adım Adım Çözüm
Anahtar Kavram
CloudWatch Agent Log Tracking and Wildcard Configuration
Tahmini Süre:2m 0s