Deploy OneAgent as Lambda extension

AWS Lambda lets you run code without provisioning or managing servers. This deployment model is sometimes referred to as "serverless" or "Function as a Service" (FaaS).

  • A Lambda function runs in an application on a container managed by AWS. This lets you focus on writing code without worrying about the underlying application or infrastructure.
  • Lambda functions are ephemeral. This means that the underlying container can be suspended or recycled when there’s no request pending.
  • Lambda functions can process only one request at a time. When there are n concurrent requests, n containers are created. All of this is completely transparent to the developer.

The Dynatrace OneAgent extension supports AWS Lambda functions written in Node.js, Python, or Java running on an Amazon Linux 2 runtime.

Overview

To deploy OneAgent as an AWS Lambda extension, use the AWS Lambda configuration page to select how you plan to deploy your Lambda function and create the corresponding configuration snippets to copy and paste. Using OneAgent deployment for AWS Lambda, you will:

  1. Choose a configuration method
  2. (Optional) Specify a Dynatrace endpoint
  3. (Optional) Enable Real User Monitoring
  4. Define an AWS layer name

Based on your configuration method, Dynatrace will provide a template or configuration for your AWS Lambda function. To get started

  1. Select Deploy Dynatrace from the Dynatrace navigation menu.
  2. Open the Download Dynatrace OneAgent page.
    • If you are using Dynatrace Hub, select the OneAgent tile and then select Download OneAgent.
    • If you are using the earlier Deploy Dynatrace page, select Start installation.
  3. On the Download Dynatrace OneAgent page, select AWS Lambda. This displays the Enable Monitoring for AWS Lambda Functions page.

Choose a configuration method

The Dynatrace Lambda agent is distributed as a layer that can be enabled and configured manually or using well known Infrastructure as Code (IaC) solutions.

On the Enable Monitoring for AWS Lambda Functions page, use the How will you configure your AWS Lambda functions? list to select your preferred method, and then make sure you set all properties for the selected method before copying the generated configuration snippets.

Specify a Dynatrace API endpoint

Optional This is an optional step that enables you to specify a Dynatrace API endpoint to which monitoring data will be sent.

The typical scenario is to deploy a Dynatrace ActiveGate in close proximity (same region) to the Lambda functions that you want to monitor in order to reduce network latency, which can impact the startup time of your Lambda functions.

Enable Real User Monitoring

Optional This is an optional step to use Real User Monitoring (RUM), which provides you with deep insights into user actions and performance via the browser or in mobile apps.

If RUM is configured, Dynatrace will display the Enable RUM with application option. When it's enabled, you can select the application that should be linked with incoming XHR requests to your Lambda function.

Define an AWS layer name

Select the AWS region and the runtime of the Lambda function to be monitored. These settings are required to provide the correct layer ARN.

Deployment

Copy the configuration snippets into your deployment and use your deployment method of choice to enable the layer and set the configuration for your Lambda functions.

Configure the AWS API Gateway

If inbound (non-XHR) requests to your Lambda functions are not connected to the calling application, configure the API Gateway to pass through the Dynatrace tag. To do this, enable Use Lambda Proxy Integration on the Integration Request configuration page of the API Gateway.

Dynatrace AWS integration

While not mandatory, we recommend that you set up Dynatrace AWS integration (SaaS, Managed). This allows data ingested via AWS integration to be seamlessly combined with the data collected by the OneAgent Lambda code module.

AWS Lambda metrics Invocations

Filter cold starts

One of the important metrics for Lambda is the frequency of cold starts. A cold start happens when a new instance of a Lambda function is invoked. Such cold starts take longer and add latency to your requests.

A high cold start frequency can indicate errors or an uneven load pattern that can be mitigated using provisioned concurrency. Dynatrace OneAgent reports such cold starts as a property on the PurePath.

To analyze cold starts, select View all requests on the Lambda service details page.

Service details page for AWS Lambda function

In the request filter, select Function cold start in the Request property section.

This displays a page that you can filter by invocations containing Only cold start or No cold start.

Screen to filter by invocations containing a Only cold start or No cold start

Known limitations

  • The Dynatrace AWS Lambda extension does not support the capture of request attributes.

  • The Dynatrace AWS Lambda extension relies on an AWS Lambda extension mechanism that is currently available for Lambda functions where the runtime is deployed on Amazon Linux 2.

  • To detect and trace invocations through Lambda functions written in Java, your function needs to use the Lambda events library for event attribute mapping, which also includes HTTP tag extraction. For details, see AWS Lambda Java Events.