DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

How I can retrieve aws lambda cloudwatch logs in txt format so I can serch on them?

As I ask below:
https://devops.stackexchange.com/q/12978/4396

I need to analyze the logs generated in cloudwatch. Therefore I want them to be downloaded as txt format. Do you know how I can do that?

Top comments (1)

Collapse
 
dansilcox profile image
Dan Silcox

You can search for a string - you will want to find the latest stream (or the one from around the time the issue occurred) in the log group for your lambda - each stream represents a particular instance - or use "insights" [some best practices here[(scalyr.com/blog/aws-lambda-logging...) to search more generally.

Longer-term, some people like to stream their CloudWatch logs into an ELK stack which makes things easier if you're used to the ElasticLog syntax. That said, once you get used to CloudWatch insights you can save yourself some time/money/moving parts by skipping the ELK part.

I'm not 100% sure on how to export them as text directly, but from a quick search it looks like you'd have to set up another Lambda to push the logs to S3, then download them from there (though I think you can set something up with Kinesis to avoid the S3 step - never used Kinesis so no clue how to do that...).