Soru

Zorluk: OrtaImproving Operational Excellence via Monitoring and Logging

A gaming company operates a real-time multiplayer game server backend on Amazon EC2 instances. The game server software writes high-throughput debug logs to a local directory at `/opt/gameserver/logs/debug.log`. These log files are rotated every 15 minutes by a custom daemon, renaming the active file to `/opt/gameserver/logs/debug.log.<timestamp>` and creating a new empty `/opt/gameserver/logs/debug.log`. The DevOps team deploys the Unified CloudWatch Agent to forward these logs to Amazon CloudWatch Logs. During peak hours, the team notices that log ingestion drops to zero for several minutes after each 15-minute rotation interval, resulting in missing critical troubleshooting data. Which configuration change should the solutions architect make to ensure continuous log collection without data loss?

  1. Update the CloudWatch agent configuration JSON by changing the `file_path` parameter to `/opt/gameserver/logs/debug.log*` to match the rotated file patterns, allowing the agent to continuously monitor and upload log data from both the active and rotated files.Cevap
  2. B
    Retain `/opt/gameserver/logs/debug.log` as the static `file_path` in the CloudWatch agent configuration, and configure the custom rotation daemon to perform an in-place truncation of the log file instead of renaming it.
  3. C
    Maintain `/opt/gameserver/logs/debug.log` as the static `file_path` in the CloudWatch agent configuration, and schedule a cron job on the EC2 instances to restart the `amazon-cloudwatch-agent` service every 15 minutes, timed immediately after the log rotation occurs.
  4. D
    Configure the CloudWatch agent to write logs to a local Amazon S3 bucket, then configure an S3 replication rule to send these logs to a central S3 bucket in a logging account, ensuring the replication rule has an IAM role that bypasses the destination bucket policy.

Cevap

Update the CloudWatch agent configuration JSON by changing the `file_path` parameter to `/opt/gameserver/logs/debug.log*` to match the rotated file patterns, allowing the agent to continuously monitor and upload log data from both the active and rotated files.
The correct answer is to update the CloudWatch agent configuration file by adding a wildcard to the `file_path` parameter. This allows the CloudWatch agent to monitor the entire pattern of files, including the active log and any rotated versions. During rotation, the agent continues tracking the renamed file to its end and begins tracking the newly created active file, ensuring zero log loss.

Adım Adım Çözüm

1
Analyze the log rotation behavior of the custom daemon on the EC2 instances.
The log files are renamed every 15 minutes, which changes the file pointer and descriptor that the CloudWatch agent is tracking.
Understanding the rotation mechanism helps identify why the static path in the configuration fails to capture logs immediately after rotation.
2
Identify the proper CloudWatch agent configuration parameter to handle rotated files.
Using a wildcard pattern in the `file_path` parameter tells the agent to watch all matching files (both the active log and the renamed files).
Wildcards allow the agent to track file modifications and new files dynamically, ensuring no logs are missed during or after rotation.
3
Implement the configuration update and verify log ingestion.
The CloudWatch agent configuration is updated with the wildcard path, and log streaming remains continuous across the 15-minute rotation intervals.
Validating the configuration confirms that both active and rotated logs are processed successfully without ingestion gaps.

Anahtar Kavram

Configuring the Unified CloudWatch Agent for Log Rotation via Wildcard File Paths
Bu soruyu puanla