An energy grid management company runs a telemetry ingestion application on a fleet of Amazon EC2 instances. The application writes log files to `/var/log/grid/telemetry.log`. A cron job rotates these logs hourly, renaming the active file to `telemetry.log.YYYY-MM-DD-HH` and creating a new empty `telemetry.log` file. The operations team configured the unified CloudWatch agent to monitor the active `/var/log/grid/telemetry.log` file, but they notice that log entries written immediately before and during the rotation process are frequently missed in Amazon CloudWatch Logs. Which configuration change will resolve this issue while maintaining operational excellence?
- Modify the CloudWatch agent configuration file by changing the `file_path` parameter to `/var/log/grid/telemetry.log*` to ensure the agent monitors both the active and rotated log files.Cevap
- BModify the log rotation cron job to stop the CloudWatch agent service before rotating the file, and then start the agent service once the new log file is created.
- CConfigure the CloudWatch agent configuration file to use `publish_multi_line_logs` pointing to the static path `/var/log/grid/telemetry.log` to flush the buffer before rotation.
- DUpdate the Amazon S3 bucket policy in the centralized logging account to allow the CloudWatch agent to directly upload the rotated files using an IAM role.
Cevap
Modify the CloudWatch agent configuration file by changing the file_path parameter to /var/log/grid/telemetry.log* to ensure the agent monitors both the active and rotated log files.
The correct option addresses the log rotation issue by using a wildcard character (`*`) in the `file_path` configuration. When the file is rotated and renamed to `telemetry.log.YYYY-MM-DD-HH`, the CloudWatch agent continues to read from the renamed file until it reaches the end of the file, while also starting to monitor the newly created `telemetry.log` file.
Adım Adım Çözüm
Anahtar Kavram
Configuring CloudWatch Agent for Log Rotation using Wildcards
Tahmini Süre:2m 0s