How to export existing log data from CloudWatch Logs to a file
- Tomasz Łakomy
Once you have the CLI installed and configured, you can use the following command to export the log data to a file:
aws logs get-log-events --log-group-name <log-group-name> --log-stream-name <log-stream-name> --output text --query 'events[*].message' > <output-file-name>
Note that you may choose to omit the
--query parameter if you want to export the entire log event, including the timestamp and other metadata. At the time of writing this command is limited to return a maximum of 1MB of data, but that should be more than enough for a nice, cozy evening read. You may also give an open source awslogs project a shot.