Announcing Support for Monitoring AWS Lambda Function URLs and Lambda Response Streaming With Datadog | Datadog

Announcing support for monitoring AWS Lambda Function URLs and Lambda Response Streaming with Datadog

Author Jordan Obey
Author Danny Driscoll
Author AJ Stuyvenberg

Last updated: April 7, 2023

AWS Lambda Function URLs make it even easier to create AWS Lambda functions that can be accessed and triggered by using HTTP/S requests, which is key for building serverless applications that are connected to and invoked from the web. Now you can generate a URL in one click that points to a specified Lambda function. Then, any HTTP/S request that a Function URL receives will trigger the Lambda function it’s assigned to. Additionally, Function URLs can be used to invoke Lambda functions with Lambda Response Streaming enabled. Lambda Response Streaming is a new AWS Lambda function capability that lets functions stream response payloads back to clients in parts rather than waiting for entire payloads to fully generate and buffer. Response Streaming helps you reduce the time to first byte (TTFB) of your applications and allows you to send responses back to clients that are larger than Lambda’s traditional 6 MiB response payload limit.

Datadog is proud to partner with AWS for the release of Function URLs by providing end-to-end visibility into requests to functions triggered by URLs, as well as key Function URL and Response Streaming metrics. In this post, we’ll look at how Function URLs work and how you can use Datadog to get deep insight into their health and performance.

Simplify your AWS Lambda–powered services

Function URLs are useful for when you want to quickly connect your Lambda functions to the web. Whereas API Gateway provides tooling for managing RESTful Lambda resources and more complex APIs, Function URLs allow you to simplify operations and deliver value to your customers more quickly. If you later decide you want to use API Gateway’s API management features—such as API versioning and custom authorization—you can easily migrate from Function URLs to API Gateway because their request payloads use the same format and contain matching fields.

Having real-time visibility into your Function URLs is critical because any duration between receiving an HTTP/S request and the resulting Lambda invocation adds to customer-facing latency. You need to be able to measure, alert on, and set SLOs by using telemetry closest to the customer experience.

Alert on Function URL duration to quickly spot and begin mitigating user-facing latency

Additionally, while Function URLs are assigned to one Lambda function, each Lambda function may have multiple associated Function URLs. This means that if a Lambda function experiences an issue, you need to be able to identify which URLs were impacted.

Next, we’ll look at how Datadog:

Investigate Function URL spans in Lambda Function traces

After instrumenting your Lambda functions, Datadog APM automatically includes Function URL spans in your request traces without any further configuration. This feature enables you to see at a glance which URLs—and therefore which end users—are affected by any issues that may occur. For example, you can see if there’s a significant delay between when a specific Function URL receives an HTTP/S request and when its associated Lambda function begins to execute. This delay could indicate that a cold start is increasing latency and that you should consider enabling provisioned concurrency.

Function URL spans are available in Lambda traces to help you identify which URLs are affected by any function issues that may occur

Function URL spans also visualize errors so that you can quickly see, for instance, if your customers are running into 5xx errors, enabling you to immediately start troubleshooting.

Monitor key Function URL metrics

Datadog collects and visualizes Function URL metrics, such as latency and counts of total requests and errors. These metrics enable you to monitor your Function URLs alongside telemetry from your Lambda functions and other AWS services you may be collecting through our AWS integration, giving you a complete view of your serverless environment. For example, you can add Function URL metrics to the AWS Lambda dashboard to easily correlate Function URL errors to Lambda function performance.

Function URL metrics are tagged by Lambda function to help identify impacted functions

Datadog automatically tags your Function URL metrics by the AWS Lambda function they trigger, so if any Function URL experiences an issue, you can see which function may be impacted. In the screenshot above, for instance, a time series graph shows counts of Function URL 4xx errors grouped by Lambda function.

Monitor Lambda functions with Response Streaming enabled

Once you enable a Lambda function to use Response Streaming, you can invoke that function using Function URLs by setting the Function URLs’ invoke mode to RESPONSE_STREAM. Datadog now supports monitoring Lambda functions with Response Streaming enabled, which means in addition to tracing and the enhanced metrics Datadog already provides, you can collect and visualize metrics generated by streaming functions. These include StreamedOutBoundBytes, which measures the amount of bytes streamed out by a particular function, and StreamedOutboundThroughput, which tracks the rate of outbound bytes per second. It’s important to collect these response stream metrics because an unexpected drop or spike in either can indicate degraded application performance. For instance, if payload sizes surpass the default response stream payload limit of 20 MiB, your functions will throttle until you either reduce the payload size or configure a new limit.

Datadog also collects and visualizes the TimeToFirstByte response metric, which measures the time between when a lambda request is invoked and when the first chunk is sent back to the end-user. Alerting on TTFB spikes, which point to degraded website and application performance, enables you to act quickly to mitigate the issue and maintain an optimal end user experience. Additionally, you can monitor the latency and duration of your streamed responses using Datadog enhanced metrics such as ResponseDuration, ResponseLatency, and ProducedBytes.

Start monitoring Function URLs today

Datadog enables you to monitor Function URL and Response Streaming performance alongside telemetry from other serverless AWS services, such as Lambda and API Gateway, in addition to over 700 other technologies. To include Function URL data in your Lambda traces, make sure that you’re using the latest version of Datadog’s Lambda libraries. Also note that Response Streaming is currently only available for Node.js Lambda functions.

If you aren’t already using Datadog, sign up today for a 14-day .