- Newest
- Most votes
- Most comments
The issue you encountered is related to how the CloudWatch agent handles symlinks, particularly with Windows paths. The CloudWatch agent has limitations when dealing with symlinked directories, especially those pointing to network locations.
When the CloudWatch agent encounters a symlink on Windows, it doesn't properly follow the symlink to the target location. Instead, it attempts to interpret the path literally, which causes the path resolution problems you observed where slashes were being omitted or paths were being incorrectly joined.
For local symlinks (not pointing to network drives), the CloudWatch agent may still have similar issues. The agent doesn't fully support symlink resolution by design, which is why you encountered these problems.
Your solution of using the direct UNC path (\hostname\share\path) was the correct approach. By providing the actual network path rather than a symlinked reference, you bypassed the symlink resolution issue entirely. This is the recommended approach when monitoring log files located on network drives.
For standard symlinked files not on network drives, you might still encounter similar issues. If you need to monitor such files, consider:
- Using the actual target path instead of the symlink path in your CloudWatch agent configuration
- Creating a copy of the logs in a local directory that the CloudWatch agent can directly access
- Using a different log collection method that better supports symlinks
The CloudWatch agent documentation doesn't explicitly mention symlink limitations, but this behavior is consistent with how the agent processes file paths, particularly on Windows systems.
Sources
How do I properly configure my cloudwatch.config file after upgrading from Amazon Linux 2 v4.5.3 to Amazon Linux 2023 v5.1.8? | AWS re:Post
answered a year ago
Relevant content
asked 3 years ago
