Datadog Serverless CLI

Datadog Serverless CLI

This feature is in open beta. Let us know of any questions or issues by filing an issue in our repo.

You can use the CLI to instrument your AWS Lambda functions with Datadog. Only Python and Node.js runtimes are currently supported.

Before you begin

Make your AWS credentials AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY available in your environment using the following cmd, or use any of the authentication methods supported by the AWS JS sdk.


Download the Datadog CI.


Configuration is done using a JSON file. Specify the datadog-ci.json using the --config argument, and this configuration file structure:

    "lambda": {
        "layerVersion": 10,
        "functions": ["arn:aws:lambda:us-east-1:000000000000:function:autoinstrument"],
        "region": "us-east-1",
        "tracing": true,
        "mergeXrayTraces": true,
        "forwarder": "arn:aws:lambda:us-east-1:000000000000:function:datadog-forwarder"


Use instrument to apply Datadog instrumentation to a Lambda. This command automatically adds the Datadog Lambda library (as a Lambda Layer) to the instrumented Lambda functions and modifies their configurations.

This command is the quickest way to try out Datadog instrumentation on an existing Lambda function. To use in the production environment, run this command in your CI/CD pipelines to ensure your Lambda functions are always updated for instrumentation.

# Instrument a function specified by ARN
datadog-ci lambda instrument --function arn:aws:lambda:us-east-1:000000000000:function:functionname --layerVersion 10

# Use the shorthand formats
datadog-ci lambda instrument -f arn:aws:lambda:us-east-1:000000000000:function:functionname -v 10

# Instrument multiple functions specified by names (--region must be defined)
datadog-ci lambda instrument -f functionname -f another-functionname -r us-east-1 -v 10

# Dry run of all update commands
datadog-ci lambda instrument -f functionname -r us-east-1 -v 10 --dry

All arguments:

–function-fThe ARN of the Lambda function to be instrumented, or the name of the Lambda function (–region must be defined)
–region-rDefault region to use, when --function is specified by the function name instead of the ARN
–layerVersion-vVersion of the Datadog layer to apply. This varies between runtimes. To see the latest layer version check the JS or python datadog-lambda-layer repo release notes
–tracingWhether to enable dd-trace tracing on your Lambdatrue
–mergeXrayTracesWhether to join dd-trace traces to AWS X-Ray traces. Useful for tracing API Gateway spans.false
–flushMetricsToLogsWhether to send metrics via the Datadog Forwarder asynchronouslytrue
–forwarderThe ARN of the datadog forwarder to attach this function’s LogGroup to.
–dry-dPreview changes running command would apply.false


For product feedback and questions, join the #serverless channel in the Datadog community on Slack.