1 Answer
- Newest
- Most votes
- Most comments
0
Enable Execution logs on API Gateway, set it to Errors and add a subscription to the CloudWatch logs group that will notify you.
You can also create an alarm on the 4xx or 5xx metric.
Relevant content
- Accepted Answerasked 3 years ago
- asked 4 years ago
- asked 8 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
Hello, thanks for your answers, the execution logs are indeed enabled and i can read the log on cloudwatch, i also created alarm that inform me when an error is returned but it does give any information that could be use to retrieve the corresponding logs, excepting the time range.
I guess the cloudwatch subscription to every log could do the tricks if setted to error but It is legal requirement for me to keep all the logs. also it does not return any information about the lambda triggered. in my case i did not find a way to create a filter properly
If you need to save all logs, you can send all logs to CWL, create a subscription filer to Lambda. The filter pattern should include the error you are looking for, e.g, "Error 500" (not sure how it actually looks in the log). When the function is invoked it gets in the event the log group and log stream so you can use that to get all the messages from that specific stream. Each log stream correlates with a single API call.