Datadog Lambda Extension

Datadog Lambda Extension

Overview

AWS Lambda extensions are companion processes that augment your Lambda functions. They run within the Lambda execution environment, alongside your Lambda function code. The Datadog extension is a lightweight version of the Datadog Agent built to run alongside your code with minimal performance overhead.

The Datadog Lambda extension is responsible for:

The Datadog extension submits custom metrics, enhanced metrics, traces and logs asynchronously. Submitting Lambda logs with the extension is supported in all Lambda runtimes. Submitting custom metrics, enhanced metrics and traces is supported in Node.js and Python Lambda runtimes.

Datadog Lambda extension Setup

To instrument your AWS serverless applications, refer to the serverless installation instructions.

As a Lambda Layer

The Datadog Lambda extension is distributed as its own Lambda Layer (separate from the Datadog Lambda Library).

  1. Instrument your Python or Node.js application by installing the Datadog Lambda Library.

  2. Add the Lambda Layer for the Datadog extension to your AWS Lambda function with the following ARN:

    arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-Extension:<EXTENSION_VERSION>
    

    Replace the placeholder values in the ARN as follows:

    • Replace <AWS_REGION> with the same AWS region as your Lambda Function, for example, us-east-1.
    • Replace <EXTENSION_VERSION> with the version of the Datadog Lambda extension you would like to use, for example 7. You can identify the current version by viewing the newest image tags in the Amazon ECR repository.

    Note: This Layer is separate from the Datadog Lambda Library. If you installed the Datadog Lambda Library as a Lambda Layer, your function should now have two Lambda Layers attached.

  3. Add the environment variable DD_API_KEY and set the value to your Datadog API key on the API Management page.

  4. Reference the sample code to submit a custom metric.

As a container image

If your function is deployed as a container image, you cannot add Lambda Layers to your function. Instead, you must directly install the Datadog Lambda Library and the Datadog Lambda extension in your function’s image.

  1. Install the Datadog Lambda Library by following the installation instructions for Node.js or Python. Use the installation instructions specifically for functions deployed as container images.

  2. Add the Datadog Lambda extension to your container image by adding the following to your Dockerfile:

COPY --from=public.ecr.aws/datadog/lambda-extension:<TAG> /opt/extensions/ /opt/extensions

Replace <TAG> with either a specific version number (for example, 7) or with latest. You can see a complete list of possible tags in the Amazon ECR repository.

  1. Add the environment variable DD_API_KEY and set the value to your Datadog API key on the API Management page.

  2. Reference the sample code to submit a custom metric.

Log collection

To disable submission of your AWS Lambda logs to Datadog using the extension, set the environment variable DD_SERVERLESS_LOGS_ENABLED to false in your Lambda function.

Further Reading

Additional helpful documentation, links, and articles: