Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log groups not created for Lambda functions #312

Closed
mdwt opened this issue Mar 12, 2020 · 18 comments
Closed

Log groups not created for Lambda functions #312

mdwt opened this issue Mar 12, 2020 · 18 comments

Comments

@mdwt
Copy link

mdwt commented Mar 12, 2020

I'm trying to debug an issue on a page that has a getServerSideProps handler, but after deploying the application I cannot find the log group for my lambda function in any of the regions.

The application uses [email protected] with getServerSideProps.

My understanding is that after deployment there should be automatically be a /aws/lambda/us-east-1.<function-name> log group in every region, correct?

My serverless.yml config:

ssr:
  component: serverless-next.js
  inputs:
    domain:
      - ${env.subdomain}
      - xxxxxxx
    memory: 2048
    timeout:
      defaultLambda: 20
      apiLambda: 15
    bucketName: xxxxxxxx
    policy: ${env.policy}

serverless.js:

class Deploy extends Component {
  async default(inputs = {}) {
    process.env.policy = getConfig().ssrPolicyArn;
    process.env.subdomain = `subdomain-${process.env.ENV}`;

    const template = await this.load('@serverless/template', process.env.ENV);
    const output = await template({ template: 'serverless.yml' });
    return output;

  }
...
...

My custom policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "dynamodb:Query",
            "Resource": "arn:aws:dynamodb:eu-west-1:xxxxxx:table/wwwwwww"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogStream",
                "logs:CreateLogGroup",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}
@malikalimoekhamedov
Copy link

Same here. Any clues?

@luismramirezr
Copy link

Here too. I'm having a 500 error and can't debug it!

@kmjennison
Copy link

For me, the log groups were created in a different region, not us-east-1. I figured I had a configuration error, but if the same happened to either of you, maybe it's an issue here.

@luismramirezr
Copy link

I didn’t found the logs. If I go to the lambda function, then monitoring, it doesn’t show any activity. There is a button to open CloudWatch logs, but after clicking it and opening CloudWatch it throws an error stating that it couldn’t open the log stream.

@kmjennison
Copy link

Did you also check the other regions in Cloudwatch? The button from the AWS Lambda console won't work if the log groups are in another region, because that link is to us-east-1.

@luismramirezr
Copy link

I couldn't find it. In which region was yours? My "default" region is us-east-1

@kmjennison
Copy link

Mine were created in us-east-2.

@luismramirezr
Copy link

I found nothing... I think it isn't being created.

@dougturnkey
Copy link

Does anyone know the trick to logging the api in this framework?

@nicovalencia
Copy link

nicovalencia commented Apr 14, 2020

Also not working for me, checked other regions and no log groups. I did, however, find a log group from a project with the exact same setup from January.

Update: I created a test event directly in the Lambda UI and it created the log group was created and logged properly. Subsequent errors/events through the actual application are still not logging.

@Jnegrier
Copy link

Jnegrier commented Apr 19, 2020

I'm facing the same problem, there an error 500 when I access the app url, and there is no way to know whats going on, looks like its only loading static content, and doesn't execute the lambda at all

@danielcondemarin
Copy link
Contributor

Hi folks, getServerSideProps still isn’t supported in the serverless component. See this RFC for details #355 how it will be implemented.
Also if you want to check the logs remember is Lambda@Edge so you will need to select the region where your incoming traffic is to see the log group.

@Jnegrier
Copy link

Thanks @danielcondemarin at the end I could find the logs in another region, and I could fix my app 👍 btw, thanks a lot for creating this tool it's impressive how easy is to deploy stuff 😄

@okarlsson
Copy link

This is probably related to the application being served with Lambda@Edge. When a user requests your website it will be rendered by a lambda in a AWS region close to that user. The resulting CloudWatch logs will then get generated in that region.

I'm located in Sweden and got logs for my requests in the eu-west-2 region (London). So try looking for logs in the region closest to you! 📍 🙂

AWS has some documentation for debugging Lambda@Edge functions here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-testing-debugging.html

@danielcondemarin
Copy link
Contributor

Closing this as it now has been answered.

@nicovalencia
Copy link

@danielcondemarin I've gone through every single region, and still cannot find the log group.

I created a test event directly in the Lambda UI and it created the log group was created and logged properly. Subsequent errors/events through the actual application are still not logging to this group though.

I even opened up the permissions completely:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "logs:*",
            ],
            "Resource": "*"
        }
    ]
}

Still not logging. Any suggestions on where to poke around? I've exhausted all documentation that I can find at this point, and would appreciate any ideas.

Thank you! 🙇

@nicovalencia
Copy link

I heard back from Amazon AWS support, and it turned out to be an issue with the Lambda function link to CloudWatch Logs. When clicking the CloudWatch link within the Lambda interface, it will now show log groups, even if you switch through each region that Lambda@Edge may have run through.

If you go into CloudFront interface, click the distribution, then go to metrics, and select your Lambda function and open in CloudWatch for that region, it will show up.

It's a bit tricky finding them, but not an issue with serverless-next.js 👍

@medv
Copy link

medv commented Aug 3, 2020

Hey this was really annoying, I would just go to CloudWatch directly and find the appropriate Log Group. Amazing if you kicked off the fix on the AWS side!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants