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

Install and configure Lambda monitoring on New Relic

Before you begin

Install Lambda monitoring

Lambda monitoring includes:

Tip

If you use the newrelic-lambda-cli to instrument your Lambda function, the linking process is automated, allowing you to bypass this step.

By linking accounts, you're granting New Relic permission to create an inventory of your AWS account and automatically gather CloudWatch metrics for your Lambda functions. After you've linked accounts, resources in your AWS account appear as entities in the entity explorer. Lambda function entities will be found in the Serverless Functions view.

You can link your AWS and New Relic account by one of the following integration methods.

For New Relic to monitor your Lambda functions, you need to set up an integration between New Relic and AWS. We recommend using Metric Streams to help reduce latency and avoid throttling of our polling requests.

If you're not using a Metric Streams integration, you can choose to set up an API Polling integration instead. By default, an API Polling integration with the Lambda service enabled will poll every 5 minutes for CloudWatch metrics.

You can use the newrelic-lambda-cli to set up an API Polling integration, but not a Metric Streams integration.

bash
$
newrelic-lambda integrations install --nr-account-id YOUR_NR_ACCOUNT_ID \
>
--nr-api-key YOUR_NEW_RELIC_USER_KEY

One step in the integrations install command will create a NEW_RELIC_LICENSE_KEY secret in AWS Secrets Manager for improved security. This is configurable with a --disable-license-key-secret flag, along with other options and flags.

Instrument your Lambda function

To instrument your Lambda function, you need an agent, and an extension. These components are bundled together in the New Relic Lambda layer. If using Lambda layers isn't an option for you, you can manually incorporate the agent and extension into your function. Based on the requirement of your Lambda function, select one of the following instrumention methods:

Use this method if your Lambda function is packaged as a Zip file and you can add layers. Layers are distribution mechanism for libraries, custom runtimes, and other dependencies. For more information, refer to Layered instrumentation documentation.

Use this method if your Lambda function can't use layers, ensuring quick deployment without the necessity to modify layers. For more information, refer to SDK based instrumentation documentation.

Use this method if your Lambda function runs inside a container. Containers provide a consistent, isolated execution environment for your applications. New Relic provides a pre-built Docker image that includes the New Relic Lambda layer, the New Relic Lambda extension, and the New Relic agent. For more information, refer to Containerized instrumentation documentation.

Configure environment variables

Tip

  • When you instrument New Relic's Lambda layer with the New Relic CLI, your mandatory environment variables are configured automatically. However, you may want to change some of the default settings and configure your Lambda functions with the environment variables that match your monitoring needs.
  • If you're using the New Relic Lambda extension, you need to configure the environment variables manually.

Environment variables are used to configure the New Relic agent and Lambda extension. It's important to set these variables correctly to ensure that your Lambda functions are monitored correctly.

Try our example functions

After you've instrumented New Relic's Lambda layer, we strongly recommend trying out our example functions. These working examples should be used as a starting point for instrumenting your own serverless functions. Using these examples can help you become familiar with the the New Relic Lambda layer, testing the account link, and they can be used as a reference for your own instrumentation. Each example demonstrates adding permissions, runtime-specific techniques for wrapping your handler, managing function log retention in CloudWatch, and more.

While there are many ways to manage and deploy Lambda functions, AWS CloudFormation is the mechanism we use for our examples.

Our examples are published, alongside the New Relic Lambda Extension, in this GitHub repository. There's one for each Lambda runtime New Relic supports:

You can also learn how to instrument distributed tracing into a non-trivial serverless application in our distributed tracing example. It illustrates manual trace propagation for SQS and SNS, two of the more popular services that might invoke Lambda functions, with Node, Python, Ruby and Java functions.

Tip

When manually testing, telemetry data can be delayed. We recommend waiting seven seconds before invoking the function again, allowing any buffered telemetry to be delivered.

Compatibility and requirement

Learn more about supported runtimes and prerequisites.

Data and UI

Learn how to use New Relic to monitor your AWS Lambda functions.

Troubleshooting

Learn how to troubleshoot installation related issues.

Copyright © 2024 New Relic Inc.

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