简体   繁体   中英

How do I find error logs for my Python lambda function across many AWS Cloudwatch log streams?

Let's say I have log group /aws/lambda/backend , which tracks logs of my Python lambda function. I want to debug common issues, like exceptions and time outs, and find related log entries.

But the function has a lot of concurrent traffic, so there are many log streams in the log group. How do I find the log entries across all logs without visiting each individual log stream and perform the search?

This is possible by using Logs Insights , which uses a query language to analyze logs in a log group.

For common Python function errors, I find this query useful:

fields @timestamp, @message, @logStream
| filter @message like /(?i)Exception|Error|Traceback|Timed out/
| sort @timestamp desc
| limit 20

This will return log queries and links to log groups to places, where exceptions or timeouts happened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM