Last active
January 9, 2024 01:19
-
-
Save bjorg/82c8b166c54bfe4f42804aae0e0b8c3f to your computer and use it in GitHub Desktop.
Download all CloudWatch logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log_group_name="/aws/log-group-name" | |
log_stream_names=$(aws logs describe-log-streams \ | |
--log-group-name "$log_group_name" \ | |
--order-by LastEventTime \ | |
--descending \ | |
--max-items 50 \ | |
--output text \ | |
--query 'logStreams[*].logStreamName') | |
for log_stream_name in $log_stream_names; do | |
aws logs get-log-events \ | |
--log-group-name "$log_group_name" \ | |
--log-stream-name "$log_stream_name" \ | |
--output text \ | |
--query 'events[*].message' | |
done > cloudwatch.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment