Wednesday, 28 August 2019

AWS CloudFront Lambda at Edge cloudwatch logs

Where are the AWS CloudFront Lambda@Edge logs and metrics?


Feb 2022 - this post is permanently moved to https://architectfwd.com, my new site, and can be found here  - https://architectfwd.com/architecture/cloud/amazon-web-services-aws/dns-domains-route-53/2022/01/23/aws-cloudfront-lambda-at-edge-cloudwatch-logs/ please go and bookmark that site for all of my future content.


You've created a lambda@Edge function to view or influence the http request/response using a Lambda function, but you cannot see any hits when looking at the monitoring tab in the function definition within AWS Lambda. Is it being hit? Here's how to find out.

Lambda@Edge


I'd created a lambda@edge function bound to a CloudFront distribution and to a specific origin event. In my instance it was to modify the default root object in a request URI for a static site hosted in AWS S3 which is fronted by CloudFront.

You've looked at the metrics in Lambda after CloudFront status for the distribution is Deployed



It looks like the function is not being triggered, why is that. Well, go over to CloudFront, look at the metrics tab and select the Lambda@Edge function, and you will see the region where the function is being triggered from, which you wouldn't be able to see by changing regions on the console.

Here's an example:


Take a look at which regions through hovering over


It looks I'm hitting Sydney, so the best place to go is the CloudWatch logs in Sydney. Take a look in the console by changing regions to Sydney, look at the Log Groups and there are my logs. The same metrics as seen in the CloudFront metrics is available in the CloudWatch metrics.

Cheers
Quintes

Quintes van Aswegen Togaf 9 Certified Architect, Professional Scrum Master I (PSM I) Certified

Connect with me on LinkedIn or Twitter