New Relic Inc.

12/07/2021 | News release | Distributed by Public on 12/07/2021 18:12

Monitoring your AWS Lambda functions inside and out

If you are not already familiar with AWS Lambda, it's a compute service that runs your code in response to events and automatically manages the underlying compute resources for you. This means that you never have to provision, manage, or maintain any servers. That's why AWS Lambda and similar services are often referred to as "serverless."

This does pose a bit of a conundrum: how do you use New Relic to monitor your servers when you don't have any!? Well, you can do it in two ways:

  1. Serverless monitoring : This allows you to see inside your AWS Lambda function. Monitor every invocation, including performance data like detailed duration, cold starts, exceptions, and tracebacks.
  2. Synthetics: If the data generated by people on a website is organic traffic, then data generated by robots is synthetic. Using New Relic One's synthetic monitors, you can script tests to monitor how our AWS Lambda function responds to external events.

Before you begin, you need to create a Lambda function to test.

If you would like to skip directly to trying the demo the source is available on GitHub. To run the application locally ensure you have Python 3.9.0 and an active virtualenv before executing the following commands in your terminal:

After you have configured the serverless CLI and completed your file, deploy the application to AWS Lambda with:

If you haven't set up a file, I'll show you how later in this blog.

You'll create a FastAPI application that will respond to an HTTP GET request with a random universally unique identifier (UUID) contained within a JSON string.