print statements in Greengrass v2 lambda not logged

0

It looks like even the simplest print statements in python 3.7 in Lambda functions for Greengrass v2 do not get logged anywhere. I've checked in /greengrass/v2/logs/<componentName>.log and /greengrass/v2/work/<componentName>/logs/0/ and don't see them. Is there some sort of config I need to add to make print statements go to the log files?

kdixson
질문됨 3년 전362회 조회
9개 답변
0

Hi,
This will be due to Python buffering the output. Please see: https://docs.aws.amazon.com/greengrass/v2/developerguide/troubleshooting.html#python-component-no-log-output.

Cheers,
Michael Dombrowski

AWS
전문가
답변함 3년 전
0

I suppose not, as the first LoC is print("up and running", flush=True). Is there anywhere else that stdout would be redirected to?

Edited by: kdixson on Apr 26, 2021 6:56 PM

kdixson
답변함 3년 전
0

The output will be in the component's logfile, located at <root>/logs/<component name>.log.

Are you certain that your lambda is actually being run? If it is running is it in container mode? If yes, you may need to increase the memory limit which is only 16MB by default and will often cause the lambda to be killed.

Please provide the code, or a minimal example which replicates the issue.

Cheers,
Michael Dombrowski

AWS
전문가
답변함 3년 전
0

Here is my code: https://gist.github.com/Lard4/28c86ae0670ef21da911b4520444c7f0

It's curious because if you comment out line 42, the topic will publish successfully, but nothing will get logged. In fact, the log file doesn't even exist in /greengrass/v2/logs.

If you leave 42 uncommented, something happens (I suppose some sort of exception gets thrown) and the lambda doesn't report a status and after 60 seconds, greengrass kills and retries the lambda. No print statements or exceptions get logged in the lambda's log. However, you can see the exception where greengrass gets no timely status report and kills the lambda. (see the greengrass.log here: https://gist.github.com/Lard4/8a7842c1f138243eacfc789033bd2e4c)

kdixson
답변함 3년 전
0

Please remove the file and stream options which are referring to sys.stdout. Just use a normal print or log statement.

Are you running in container mode? As I mentioned before, it is possible that it is running out of memory and being killed.

It is not possible for the component's log file to not exist; the log file is created just as soon as the component is deployed to the system.

Please provide the contents of <root>/configs/effectiveConfig.yaml file.

Cheers,
Michael Dombrowski

AWS
전문가
답변함 3년 전
0

I've tried it both in a container and not in a container. Both don't log anything. Here is my effectiveConfig.yaml: https://gist.github.com/Lard4/d3d7ef24fdce17dcd3c63686f3b86908

Note that the lambda under investigation is called DataIngestionLambda

Edited by: kdixson on Apr 27, 2021 11:06 AM

kdixson
답변함 3년 전
0

I just removed the sys.stdout from the print statements, and no log file is being created.

kdixson
답변함 3년 전
0

Please attach the entirety of the logs directory to this forum post so that I can review all the logs.

Cheers,
Michael Dombrowski

AWS
전문가
답변함 3년 전
0

I ended up uninstalling greengrass and reinstalling, this fixed my issues

kdixson
답변함 3년 전

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

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

질문 답변하기에 대한 가이드라인

관련 콘텐츠