Monitoring AWS Lambda functions with Datadog | Datadog
Network Performance Monitoring is now generally available! Network Monitoring is now available!

Monitoring AWS Lambda functions with Datadog

Author Evan Mouzakitis
@vagelim

Published: August 10, 2016

The “serverless” movement is taking the industry by storm and now, with Datadog, you can start monitoring your serverless applications and functions on AWS Lambda.

As soon as you enable the Lambda integration, you’ll start to see your metrics in an out-of-the-box dashboard like the one above.

Monitor and alert on AWS Lambda serverless functions in minutes with Datadog.

AWS Lambda is an event-driven compute service that abstracts away the underlying infrastructure, allowing developers to focus on their code rather than the execution environment. Lambda functions can be triggered via API, by in-app actions, or by AWS events, such as a new object being added to an S3 bucket. Since its debut in 2014, Lambda adoption has flourished, with a rich ecosystem of tooling and frameworks developing around it, and adoption by large companies like Netflix and Nordstrom.

As part of AWS, Lambda integrates with several AWS services you may already be using. These services include: EC2, ELB, SES, and S3. Its affordability, reliability, convenience, and native integration with other AWS services make Lambda the go-to computation-as-a-service platform.

Monitoring AWS Lambda serverless environments

Monitoring Lambda function execution and performance is a bit different than monitoring a traditional application server. With no “host” in the traditional sense (and thus nowhere to run standard diagnostic and monitoring tools) monitoring Lambdas without living in the AWS management console can be challenging.

Peeling back the curtain

With Datadog’s integration with AWS Lambda, you can now visualize and alert on Lambda metrics and logs, and put them in context with operational data from the rest of your infrastructure. Instead of clicking through the AWS console for your function’s execution metrics, now you can see them all in one place.

Show me the metrics!

Using our Lambda integration, you’ll be able to alert on and visualize metrics on your functions’ execution, including:

  • execution times
  • invocations
  • errors
  • throttled functions

Slice ‘em up with tags

The integration automatically adds tags to your Lambda functions, so you can use these new dimensions to slice and dice your data any way you like. That includes tags such as:

  • functionname: the name of the Lambda function
  • region: the region in which the Lambda is “located”
  • any custom tags you added to your functions

Datadog also automatically adds tags for your Lambda runtime language, allocated memory, and AWS account.

Beyond standard metrics

You can also collect and send custom metrics with the Datadog Lambda Layer, so you can monitor function-specific metrics alongside metrics from the rest of your infrastructure.

To start sending your own custom metrics, add the Layer ARN to the appropriate Lambda function in your AWS console:

arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-<RUNTIME>:<VERSION>

You can find the latest Layer version on the GitHub releases page for your runtime.

Datadog offers Lambda Layers for several programming languages and runtimes, including Python, Go, and Node.js, so you can easily import the necessary Lambda methods into your existing code. Once your custom metrics are flowing into Datadog, you can track automatically calculated, real-time aggregations (average, sum, max, min, count, and percentile values).

Check out our documentation for more information about sending and tagging custom metrics with the Datadog Lambda Layer.

Collect serverless traces and logs

You can also collect traces for AWS Lambda by enabling Datadog’s AWS X-Ray integration. This allows you to visualize requests as they move across your infrastructure—from AWS Lambda functions to hosts, containers, and services.

In addition to collecting metrics and traces, you can automatically collect and forward your Lambda logs to Datadog. This enables you to quickly pivot from a Lambda metric or trace to related logs (e.g., by clicking the “Logs” tab in the trace above), so you can get a comprehensive view of Lambda activity all in the same place. Check out our documentation for more information on forwarding Lambda logs to Datadog.

Verifying permissions

If you haven’t already integrated AWS with Datadog, take a minute to do so before continuing.

Next, add the following permissions to your Datadog IAM policy to start collecting AWS Lambda metrics:

  • lambda:List*
  • tag:GetResources

Flip the switch

Once you’ve integrated Datadog with Amazon Web Services, you can turn on the integration right away, and add AWS Lambda to the ever-growing list of technologies you can monitor easily and collaboratively. If you’re new to Datadog, get started with a .