跳至內容

Retrieving the log stack on API Gateway 4XX error 5XX error

0

When There is an error during an API gateway call I can find thanks to Cloudwatch X-ray the log trace of the error including all the log of api gateway and all the log of the lambda triggered by the call.

I would like to receive of reccord this log every time API gateway return a 4XX or 5XX to be able to invesgate quicker, what is the way to trigger an event with all the required information ?

1 個回答
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.

AWS
專家
已回答 2 年前
  • 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.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。