I needed to grep through the logfiles manually, and found a way to do this:
- Download the logfiles recursively from S3 to the local dir:
aws s3 cp --recursive s3://<bucket name>/<bucket subdir>/ ./
- Different streams in my Cloudwatch log group are from different applications with different timestamp formats, so grep out the one I want recursively using
zgrep -r.
- My logfile line looks like this:
api-api-0f73ed57-e0fc-4e69-a932-4ee16e28a9e6/000002.gz:2017-02-02T22:48:49.135Z [2017-02-02 22:48:49] Main.DEBUG: Router threshold 99.97 [] {"ip":"10.120.4.27"}
- So use
sort -sk<key 1>,<key 2> to sort on the second and third whitespace-separated fields ([2017-02-02 and 22:48:49])
- This gives me the following command:
zgrep -r api-api logfile* | grep "Main.DEBUG" | sort -sk2,3
Thanks to the following question for the tips on sort.