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 Lambda Library layer to apply. This varies between runtimes. To see the latest layer version check the JS or python datadog-lambda-layer repo release notes
–extensionVersion-eVersion of the Datadog Lambda Extension layer to apply. When extensionVersion is set, make sure to export DATADOG_API_KEY (or DATADOG_KMS_API_KEY) in your environment as well. While using extensionVersion, leave out forwarder Learn more about the Lambda Extension here
–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

Additional Environment Variables:

You may configure the lambda instrument command with environment variables: You must expose these environment variables in the environment where you are running datadog-ci lambda instrument

Environment VariableDescriptionExample
DATADOG_API_KEYDatadog API Key. Sets the DD_API_KEY environment variable on your Lambda function configuration. For more information about getting a Datadog API key, see the API key documentationexport DATADOG_API_KEY=“1234”
DATADOG_KMS_API_KEYDatadog API Key encrypted using KMS. Sets the DD_KMS_API_KEY environment variable on your Lambda function configuration.export DATADOG_KMS_API_KEY=“5678”
DATADOG_SITESet which Datadog site to send data. Only needed when using the Datadog Lambda Extension. Possible values are , , and The default is Sets the DD_SITE environment variable on your Lambda function configurations.export DATADOG_SITE=“”


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