How to connect APM to a Node JS 12.x serverless AWS lambda using promise

How to connect APM to a Node JS 12.x serverless AWS lambda using promise. Followed the steps in the setup. however no result displayed in APM

Also I am not using express. The current setup is using promise

Hi @snair24,

Great question! The relationship between APM agents and AWS Lambda functions is likely something many people have questions about.

First, which set of instructions did you follow?

A little background, New Relic APM and New Relic Lambda Monitoring of AWS Lambda (that’s a mouthful) provide different things. APM provides observability into transactions sent to the New Relic collector via Agents based on your app’s language for certain, popular frameworks like Express. This is typically implemented on a backend server like an AWS EC2 instance. New Relic Lambda Monitoring provides observability into function invocations and distributed traces around those functions.

One of our engineers said it best:

In the serverless offerings for Node and Python, we bundle the standard current agent for the language (and with our serverless lambda layers which can pick up monitoring without explicit code changes). But the Lambda ingest pipeline does ignore certain kinds of data (transactions) that would be standard for APM contexts.

In other words, if you’re using NodeJS 12.x, you’ll be able to get New Relic Monitoring of AWS Lambda quite easily and without code changes by following the New Relic Lambda setup.

However, APM won’t really come into play unless you are using the Node Agent on a server with a supported framework. Is Promise your framework? If so, I don’t see it in the list of frameworks that we automatically instrument, so your results with that framework may vary. If you are referring to the use of native promises with a supported framework, that will work with the Node Agent on a backend server like what EC2 provides.

With New Relic Lambda Monitoring, you’ll be able to see:

  • Lambda function invocations (with performance data)
  • Invocations for other AWS services
  • Distributed traces (if enabled)
  • What triggered the Lambda

NR Lambda also has its own UI.

Additional details from our engineering team:

New Relic Lambda Monitoring does not require use of the Node Agent as a prerequisite, because the layers contain the Agent. It also does not require you to wrap your AWS Lambda functions by using serverless-newrelic-lambda-layers. A backend server is not required, though some people use Express.

If running Express in a Lambda, it is possible to use an adapter like aws-serverless-express, though you’ll see a double count of invocations unless you implement a fix which is in the process of being documented.

The New Relic Agents bundled in the layers facilitate auto-monitoring without needing to manually wrap and instrument code.

2 Likes

Thank you for the response. I tried following the Install the Node.js Agent steps which didnt wor. So is the option to use serverless-newrelic-lambda-layers. Also what is the configuration to use APM in case of serverless.

Hey @snair24,

With New Relic Monitoring of AWS Lambda you’ll get a new UI that is not part of APM. The serverless-newrelic-lambda-layers is an option in the installation procedures that allows you to wrap your AWS Lambda functions without any code changes. Give it a try to see if you like it.

https://docs.newrelic.com/docs/lambda-monitoring-ui

Running the APM Node Agent in AWS Lambda has not been well tested, meaning it may be challenging to make it work there. Here’s a list of recommended hosting services for use with the Node Agent.

https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent#h2-hosting-services