2

A lambda that I have deployed has gone wrong. Therefore, I want to look on logs and find out whats wrong about it. Hence I look upon cloudwatch logs for any error message.

But the cloudwatch environment allows no easy way to search for a string in logs. Therefore I need to download a portion of it in text format so I can grep string in it. Do you know how I can do that?

1 Answer 1

1

There are several ways for exporting logs from CloudWatch in searchable text format:

The easiest way of downloading logs in text format is to go to a log group -> Select a log stream -> go to Actions and select Download search results as CSV:

enter image description here

This will download the logs in a .csv format which may or may not be what we want, nevertheless I think it is good for searching a analysis.

A more involved way to export logs would be to select a log group and from the Actions and for that log group select Export Data to S3:

enter image description here

This may export every stream from the log group to an S3 bucket, from which we can download the logs in text format. In order to be able to write to an S3 bucket, we need a policy. There is a full documentation on the AWS docs about how to do this.

I need to mention the CloudWatch provides a way to analyze logs without being able to export them by using CloudWatch Logs Insights. CloudWatch Logs Insights has its own query language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.