내용으로 건너뛰기

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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠