• EnglishEspañol日本語한국어Português
  • Log inStart now

Instrument your containerized image layer

If you're using a containerized image for Lambda and want to monitor your application, you'll need to add New Relic to your code. After you add our pre-built layer to your image, push the image to your AWS Elastic Container Registry. From there, whenever you run your function, New Relic will run at the same time.

Here's a guide to adding our pre-built layer to your code.

Add New Relic to your Dockerfile:

New Relic offers pre-built images that include our layer's different runtimes: Java, Node.js, Python, and extension-only.

  1. Select the layer compatible with your specific Lambda function's runtime and region:
  1. At the top of your Dockerfile add the following code:
FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-java:17-arm64 AS layer
# Layer code
COPY --from=layer /opt/ /opt/
FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-python:38-arm64 AS layer
# Layer code
COPY --from=layer /opt/ /opt/
FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-nodejs:20-arm64 AS layer
# Layer code
COPY --from=layer /opt/ /opt/
FROM public.ecr.aws/newrelic-lambda-layers-for-docker/newrelic-lambda-layers-lambdaextension:x86 as layer
# Layer code
COPY --from=layer /opt/ /opt/

Create an image

  1. After you add the New Relic pre-built layer to your Dockerfile, you'll need to build a new image from the Dockerfile. This new image will have your original code and New Relic's layer. To do this, we recommend following the steps listed in the AWS guide, Pushing a Docker image.
  2. Push the new image to your AWS Elastic Container Registry (ECR) repository for deployment.

Configure your Lambda function

  1. Create a new Lambda function using the image you pushed to AWS ECR. For more information on how to create this function, we recommend reviewing the AWS guide: Working with container images.
  2. Configure the Lambda function with the same settings as your original function, but ensure you add any required environment variables for New Relic Lambda monitoring.
  3. Update your function's handler to point to the newly attached layer in cmd override for your function. You can do that using the instructions in these two docs:
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.