serverless-nextjs/serverless-next.js

Flag to enable lambda debug logging

Open

#882 建立於 2021年1月21日

在 GitHub 查看
 (1 留言) (2 反應) (0 負責人)TypeScript (3,998 star) (447 fork)batch import
enhancementgood first issue

描述

Is your feature request related to a problem? Please describe.

I am trying to debug issues around rewritting paths in next and as part of that the logging in cloud watch is not sufficient to identify issues on underlying servers.

For example, on the the domain a page is host on old.example.com/page the page renders successfully, but when we rewrite in next example.com/rewitten-page thats purpose is to proxy old.example.com/page but instead it 502's

Here is the cloudwatch logs, where you can see there is a json error in the response

  | 2021-01-21T00:00:00.000+00:00Copy(<CLOUDWATCH_ID>) INFO START processing EventType: origin-request LambdaFunctionARN Method: GET URI: /page-502 | (<CLOUDWATCH_ID>) INFO START processing EventType: origin-request LambdaFunctionARN Method: GET URI: /page-502
  | 2021-01-21T00:00:00.000+00:00Copy(<CLOUDWATCH_ID>) INFO Invoking LambdaFunctionARN Region: eu-west-1 | (<CLOUDWATCH_ID>) INFO Invoking LambdaFunctionARN Region: eu-west-1
  | 2021-01-21T00:00:00.000+00:00Copy(<CLOUDWATCH_ID>) INFO Response received from Lambda: <REQUEST_ID> | (<CLOUDWATCH_ID>) INFO Response received from Lambda: <REQUEST_ID>
  | 2021-01-21T00:00:00.000+00:00Copy(<CLOUDWATCH_ID>) ERROR Validation error: The Lambda function returned an invalid json output, json is not parsable. | (<CLOUDWATCH_ID>) ERROR Validation error: The Lambda function returned an invalid json output, json is not parsable.
  | 2021-01-21T00:00:00.000+00:00Copy(<CLOUDWATCH_ID>) INFO END processing EventType: origin-request LambdaFunctionARN | (<CLOUDWATCH_ID>) INFO END processing EventType: origin-request LambdaFunctionARN

But the lambda logs for that request looks

2021-01-21T00:00:00.000+00:00

Copy
START <REQUEST_ID> Version: 36
START <REQUEST_ID> Version: 36	2021/01/21/[36]<LOG_GROUP_ID>

2021-01-21T00:00:00.000+00:00

Copy
END <REQUEST_ID>
END <REQUEST_ID>	2021/01/21/[36]<LOG_GROUP_ID>

2021-01-21T00:00:00.000+00:00

Copy
REPORT <REQUEST_ID>	Duration: 948.89 ms	Billed Duration: 950 ms	Memory Size: 512 MB	Max Memory Used: 87 MB	
REPORT <REQUEST_ID> Duration: 948.89 ms Billed Duration: 950 ms Memory Size: 512 MB Max Memory Used: 87 MB	2021/01/21/[36]<LOG_GROUP_ID>

It would be awesome if we can toggle more detailed logging for debugging purposes

Describe the solution you'd like

An option in the serverless.yml config that enables logging for the inbound request and outbound response to cloudfront.

Describe alternatives you've considered

Having an always enabled explicit logging, but that feels like it might cost people more money that they may want to pay.

Additional context Add any other context or screenshots about the feature request here.

貢獻者指南

Flag to enable lambda debug logging · serverless-nextjs/serverless-next.js#882 | Good First Issue