Troubleshoot enabling serverless monitoring of AWS Lambda

Problem

You’re attempting to enable serverless monitoring for AWS Lambda and are having an issue or error.

Solution

There are two common problems related to not completing all of the enablement procedures:

  • Not seeing data on CloudWatch metrics UI page. This means the AWS integration step wasn't completed.
  • Not seeing data on Troubleshooting category UI pages. If you aren't seeing data on the Distributed tracing, Errors, and Invocations UI tabs, this means the APM agent instrumentation step wasn't completed.

Besides these basic enablement problems, there are some additional problems that may cause an issue:

  • CloudWatch error "HTTP error 401: unauthorized." This is due to an incorrect API Key. The --nr-api-keyargument in the Configure AWS enable step takes your personal API key, which is different from the REST API key. For more on this, see Generate a personal API key.
  • Custom metrics are missing. Lambda monitoring is not compatible with our custom metrics. Use custom attributes to add metadata.
  • Invocations missing. To see invocation breakdown details, distributed tracing must be enabled as part of the Lambda instrumentation step. Distributed tracing is required so that span details can be displayed in the invocation details pane.
  • You've completed the installation, integration, and instrumentation steps correctly, and your function is sending logs to CloudWatch but you're not seeing traces for specific dependencies (or any traces) in the UI. This may result from the order of layer merging (if you're using our Lambda layers) or from the order of import (if you're instrumenting manually):

    • If you're instrumenting with layers: make sure in your function configuration that the New Relic layer is merged before other layers (though if your function uses webpack, the New Relic layer should be merged after the webpack layer).

    • If you're instrumenting a Node function manually, make sure that your function imports newrelic and @newrelic/aws-sdk before it imports any dependencies you expect to monitor.

If none of these solutions help you, contact our support team. The following information will help you when you talk to support technicians:

  • Has the Lambda function appeared in the UI before? If so, what is the name of the function?
  • If some data for the Lambda function is appearing in the UI, what specific data is appearing?
  • What APM language agent are you using to instrument the function?
Recommended: Attach your CloudWatch logs to the ticket

To provide our support team with logging information when opening a ticket:

  1. Invoke the function in AWS Lambda.
  2. Click on the logs link after your function runs.
  3. This will take you to the CloudWatch logs in AWS. On the left-hand sidebar in AWS, under Logs, click on Insights.
  4. Select your function and also the newrelic-log-ingestion stream.
  5. Apply an appropriate Time Filter, and a log entry limit (the default of 20 may not be enough).
  6. Under Actions select Copy query results (ASCII).
  7. Paste the copied text into a new text file, then save and upload the text file to the ticket.

The NR_LAMBDA_MONITORING payload contains all the information the agent attempts to send up, including metrics, events, some AWS account metadata, invocations and errors data. Note that some of that data (for example, our legacy metrics) will not make it to our UI because our ingest pipeline does not consume them.

For more help

If you need more help, check out these support and learning resources: