I want to troubleshoot Amazon CloudWatch logs that fail to export to Amazon Simple Storage Service (Amazon S3) buckets.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you use the most recent AWS CLI version.
Troubleshoot based on whether the logs fail when you're creating the export task or after you create the export task.
Logs don't export during task creation
To troubleshoot tasks that fail when you create them, take the following actions:
Logs don't export after task creation
To troubleshoot tasks that fail after you create them, check the time range setting. If you export log streams that have large amounts of data and specify a long time range, then the export task might fail. To resolve this issue, configure shorter time ranges to export log streams.
To check the status of the time range setting, run the following describe-export-tasks AWS CLI command:
aws logs describe-export-tasks --task-id example-task-id
Note: Replace example-task-id with your task ID.
To shorten the time range, run the following create-export-task AWS CLI command and modify the --from and --to values:
aws logs create-export-task --task-name "example-task-name" --log-group-name "/aws/lambda/example-log-group-name" --destination "example-bucket-name --from 1710378735 --to 1710465135
Note: Replace example-task-name with your task name, example-log-group-name with your log group name, example-bucket-name with your destination bucket.
To check the status of the export task, run the following describe-export-tasks AWS CLI command:
aws logs describe-export-tasks --task-id example-task-id
Note: Replace example-task-id with your task ID.
The logs might take up to 12 hours to be available for export. The export task can also take up to a few hours to process. This process depends on the size of the data that you export. It's a best practice to use log group-level subscription filters to process in real time or continuously archive new data to Amazon S3. For more information, see Real-time processing of log data with subscriptions.
Related information
Why is the log data that I exported from CloudWatch to Amazon S3 either missing or invalid?
How do I retrieve log data from CloudWatch Logs?
Exporting log data to Amazon S3