The New Relic Lambda monitoring stack
There are several important parts to Lambda monitoring:
- Your function
- The New Relic agent or SDK
- The New Relic Lambda Extension
- New Relic's backend
- The New Relic Lambda UI
Your function is the code you want to understand. You want to know when it's encountering errors, why it's slow, or how often it gets invoked.
New Relic agent or SDK
This is a library that New Relic provides for the language that your function is written in. Its job is to do the actual monitoring of your code. It measures the duration of your function invocations, notes errors that occur, records details about the source events, and your functions responses. To do this, it needs to wrap around your Lambda invocation handler function.
With a bit more work on your part, you can break your invocation into interesting segments, and tie together the interaction of your function with other functions and services, providing a holistic view of your serverless application.
New Relic Lambda Extension
This sidecar process runs inside the Lambda execution environment, alongside your code. It enhances the telemetry that the agent collects, and sends it to New Relic's backend in batches. It can also send your function's logs to New Relic.
The extension is a small application that integrates tightly with the AWS Lambda lifecycle, and works to minimize both the time it takes your telemetry to arrive at New Relic, and the impact that instrumentation has on your function's latency and throughput.
See more about our Lambda extension.
New Relic's backend
Lambda UI in New Relic
Lambda functions aren't quite like traditional services, so the experience of managing them is a little different from the classic APM experience. Inside the New Relic platform, Lambda functions have a custom UI, which quickly surfaces the most important information about your function, and integrates closely with our logging and distributed tracing features.
The legacy CloudWatch path
Older integrations send telemetry in a slightly different way. Instead of passing telemetry off to the extension, the agent writes it out to CloudWatch as a log line.
By adding a log subscription filter to pipe your function logs into the
aws-log-ingestion Lambda function, we can recover that CloudWatch log line, and forward it on to New Relic, along with some other platform telemetry.
In the past, we've seen that this approach has some considerable drawbacks. The AWS CloudWatch service can generate a lot of data. If you're on our Free edition, you may hit your data limit pretty quickly. If you're paying for data, you may find this service making up the largest share of the data you're sending to New Relic.