AWS Lambda Logs using AWSCLI: How can I access Lambda logs using AWSCLI?

后端 未结 2 1361
既然无缘
既然无缘 2021-02-04 06:48

I was trying to work with AWS Lambda using the awscli on an ubuntu ec2 instance, and I do not have access to the aws console. Note that I am not using serverless or zapper, I di

2条回答
  •  情话喂你
    2021-02-04 07:00

    Using the AWS CLI can be a bit irritating because the stream name changes as you modify your function. I've found that using awslogs (https://github.com/jorgebastida/awslogs) is a nicer workflow.

    List the groups:

    awslogs groups
    

    Filter results.

    awslogs groups|grep myfunction
    

    Then get the logs from the group.

    awslogs get /aws/lambda/ShortenStack-mutationShortenLambdaBC1758AD-6KW0KAD3TYVE
    

    It defaults to the last 5 minutes, but you can add the -s parameter to choose a time, e.g -s 10m for the last 10 minutes.

    The output is colourised if you're at the terminal, or plain if you're piping it through other commands, e.g. grep to find something.

提交回复
热议问题