Why is the log data that I exported from CloudWatch to Amazon S3 either missing or invalid?

2 minute read
0

I configured Amazon CloudWatch to export log data to Amazon Simple Storage Service (Amazon S3). Then, I used the AWS Command Line Interface (AWS CLI) to export the log data to Amazon S3. However, I couldn’t locate any useful log file data at the Amazon S3 destination.

Short description

The missing or invalid exported log data issue occurs when you don't specify the time interval for the log data. To specify the time interval, use timestamps that are expressed as the number of milliseconds that elapsed since Jan 1, 1970 00:00:00 UTC.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you use the most recent AWS CLI version.

To export CloudWatch log data to Amazon S3, use starting and ending timestamps that are expressed in milliseconds to specify the time interval.

For example, the following create-export-task AWS CLI command exports CloudWatch log data to Amazon S3 with timestamps set from 1718956360000 to 1718963560000:

aws logs create-export-task --task-name "example-task" --log-group-name "/var/logs/example-logs" --from 1718956360000 --to 1718963560000 --destination "log_bucket" --destination-prefix "example-logs"

Related information

Linux command to get time in milliseconds on the Stack Overflow website