A media company runs a critical content delivery application on a fleet of Amazon EC2 instances. The application writes log data to `/var/log/app/access.log`. To manage local disk space, a log rotation utility runs hourly, renaming the active file to `/var/log/app/access-YYYYMMDD-HH.log` and creating a new empty `/var/log/app/access.log` file. The company uses the Unified CloudWatch Agent to stream these logs to Amazon CloudWatch Logs. During testing, log ingestion into CloudWatch Logs stops immediately after the first hourly log rotation completes. Which action should the Solutions Architect take to resolve this issue and ensure continuous log ingestion?
- Modify the Unified CloudWatch Agent configuration file by changing the `file_path` parameter under the logs section to `/var/log/app/access*.log`.Answer
- BRetain the static `/var/log/app/access.log` path in the agent configuration file, and configure a cron job to restart the Unified CloudWatch Agent service immediately after each hourly log rotation.
- CModify the S3 bucket policy in the centralized logging account to allow the EC2 instances' IAM role to perform `s3:PutObject` operations using a wildcard for the log file names.
- DSpecify the static `/var/log/app/access.log` path in the agent configuration file, and enable the `auto_reload` parameter in the agent's global settings block.
Answer
Modify the Unified CloudWatch Agent configuration file by changing the `file_path` parameter under the logs section to `/var/log/app/access*.log`.
Modifying the file path to use a wildcard pattern allows the Unified CloudWatch Agent to monitor the directory for new log files matching the pattern. When log rotation occurs, the agent will dynamically discover the newly created active log file and continue ingestion without interruption.
Step-by-Step Solution
Key Concept
Configuring the Unified CloudWatch Agent to handle log rotation using wildcard path patterns.
Estimated Time:1m 30s