- Newest
- Most votes
- Most comments
I wanted to report that I corrected this by (also Windows Server 2019):
- Stop AmazonCloudWatchAgent service
- Delete State files under "{Install_Directory}\AmazonCloudWatchAgent\Logs\state*"
- Edit "{Install_Directory}\AmazonCloudWatchAgent\amazon-cloudwatch-agent.json" as follows with the uppercase UTF-16 (not sure if that is all that will work but I am so done with trying stuff): { "file_path": ..., "log_group_name": ..., "log_stream_name": ..., "timestamp_format": ..., "multi_line_start_pattern": "{timestamp_format}", "encoding": "UTF-16" }
- Start AmazonCloudWatchAgent service.
Hope this resolves it for you too.
answered a year ago
The issue you're experiencing with CloudWatch Agent file encodings is related to how the agent handles different character encodings.
According to the CloudWatch Agent documentation, there is indeed an encoding parameter that can be specified in the configuration file for log collection. This parameter allows you to specify the encoding of the log file so that it can be read correctly. The default value is utf-8.
For UTF-16LE encoding, the correct parameter value should be utf-16le (which you tried). The documentation lists both utf-16 and utf-16le as valid encoding options. When specifying an incorrect encoding, there might be data loss because characters that cannot be decoded are replaced with other characters, which explains the garbled output you saw.
The fact that logs stopped streaming when you specified the encoding suggests there might be an issue with how the agent is processing the encoding parameter on your Windows Server 2019 environment. This could potentially be a bug in the version you're using (1.300057.0).
To troubleshoot this further:
-
Check the CloudWatch agent logs located at
$Env:ProgramData\Amazon\AmazonCloudWatchAgent\Logs\amazon-cloudwatch-agent.logfor any error messages related to encoding. -
Enable debug logging by setting the
debugfield totruein theagentsection of your configuration file, then reconfigure and restart the agent. This will provide more detailed information in the logs. -
When making configuration changes, ensure you're using the
fetch-configoption when restarting the agent to properly apply the new configuration.
The encoding values should be coming from Python's codecs.decode() function, not from .NET classes, as the CloudWatch agent uses these encoding standards.
Sources
Manually create or edit the CloudWatch agent configuration file - Amazon CloudWatch
CloudWatchLogsLogStream - OpsWorks
Troubleshooting the CloudWatch agent - Amazon CloudWatch
Issue with CloudWatch agent configuration | AWS re:Post
CloudWatch Logs agent reference - Amazon CloudWatch Logs
answered a year ago
All of these have already been confirmed as working fine. The issue still persists.
This is affecting us as well.
In our case it is specifically MSSQL server logs on Windows Server 2019 "Datacenter" being sent via Cloud Watch Agent [ CWAgent/1.300057.1b1167 (go1.24.4; windows; amd64) ] to AWS CloudWatch.
I have attempted the above like requested of Gabe, I did not see encoding mentioned in the logs.
I have tried all the encodings.
Default (UTF8) the logs have the extra space.
When I pick UTF16LE, utf16le, utf16, UTF16 it gives garbage characters.
External tools confirm the file is encoded UTF16-LE.
If there are any other suggestions please let me know.
Relevant content
- AWS OFFICIALUpdated 3 years ago

After doing the same this resolved our issue, thanks!