Thundra: Serverless Observability for AWS Lambda

The black box nature of AWS Lambda and other serverless environments means that identifying and fixing performance issues is difficult and time-consuming. Built for straightforward debugging, monitoring, and observability, Thundra provides deep insight into your entire serverless environment. Thundra collects and correlates all your metrics, logs, and traces, allowing you to quickly identify problematic invocations and also analyzes external services associated with that function. With Thundra’s zero overhead and automated instrumentation capabilities, your developers are free to write code without worrying about bulking up their Lambdas or wasting time on chasing black box problems.

Get Started    Discussions

Installation and Configuration


With AWS Lambda Layers

With AWS Lambda Layers you do not have to install Thundra modules before uploading your function to AWS Lambda.

You just need to wrap your lambda function handler with Thundra as shown below:

const thundra = require("@thundra/core")({ apiKey: "MY_APIKEY" });

exports.handler = thundra((event, context,callback) => {
    callback(null, "Hello Thundra!");

To initialize your Thundra variable in your function, you can pass in your Thundra generated API key.

After deploying your function you need to add Thundra's Node.js Layer. Adding Node.js layer adds Thundra dependency to your application:

  • First, go to your AWS Lambda Function Page and Click Layers in the Designers tab.
  • Then Click Add Layer
  • Select Provide a layer version ARN and copy arn:aws:lambda:<aws-region>:269863060030:layer:thundra-lambda-node-layer:<latest-version> the latest ARN of Thundra Node Layer and then click add. For this example, since we are using us-west-2 region, ARN value will be arn:aws:lambda:us-west-2:269863060030:layer:thundra-lambda-node-layer:<latest-version>. Latest version of the layers can be seen here
  • You have successfully installed Thundra to your Node.js Lambda function. Now you can simply invoke your function and monitor it through Thundra console.

Without AWS Lambda Layers

Installation is extremely simple with the npm command in the directory of your project.

npm install @thundra/core --save

After installing the thundra/core module, you will need to wrap your handlers to require Thundra’s core module and pass the API key you generated or the API key created when your first login. Thundra will monitor your AWS Lambda functions automatically, supporting ‘callback’ along with various ‘context’ functions.

const thundra = require("@thundra/core")({ apiKey: "MY_APIKEY" });

exports.handler = thundra((event, context,callback) => {
    callback(null, "Hello Thundra!");

Automatic Wrapping

If you do not want to change your code you may also automatically wrap your Node.js function handlers by using Thundra's automatic wrapping capabilities for Node.js. This is a non-invasive method to wrap your functions and can be done when deploying your lambda functions using serverless.You can read about automatic wrapping in more detail here.


Configuring your Lambda functions allows you to control what information you would like to monitor and how you would like to monitor it. This includes monitoring modes such as synchronous or asynchronous monitoring. Thundra for Node.js functions can be configured in three ways, providing flexibility in how you prefer to monitor your applications. These include:

A detailed list of configuration variable can be found here

After you have successfully configured your lambda function as per the steps above, you can expect to see invocation details of your Lambda function on the Thundra Web Console. This includes displaying your invocation Trace as a single Span. To see more detailed Span information, you can instrument your function further, either manually or automatically.

Serverless Framework Configuration

Serverless deployment is facilitated by using Thundra’s environment variables and setting them in your serverless.yml file. Deploying your serverless application will set these variables and allow Thundra to monitor your functions.

Async Monitoring

The example illustrated above shows configurations for Async monitoring, which differs from synchronous monitoring concerning the plugin serverless-plugin-thundra-monitoring-cw and with the environment variable thundra_agent_lambda_report_cloudwatch_enable being set to true. Detailed information about Async monitoring can be found here.

Automatic Wrapping

When deploying your lambda functions using the serverless.yml file, you can use Thundra's serverless plugin to allow automatic wrapping of your functions.

Install the Thundra's serverless plugin using npm install serverless-plugin-thundra, and add serverless-plugin-thundra under the plugins section of your .yml file. Ensure you have the Thundra's node agent installed and enter your api key in the .yml file as shown in the illustrations above.

  - serverless-plugin-thundra

Programatic Configuration

You can configure Thundra monitoring in your code base itself using module initialization parameters and are set when wrapping your handler.

Configuration Precedence

It must be noted that environment variables have a higher precedence over initialization parameters.

The example in the code snippet below gives an insight of how to configure your Lambda functions programmatically.

const thundra = require("@thundra/core"); //Require Thundra node module

const thundraWrapper = thundra({ //Programmatic configurations
    apiKey: "demo-thundra-api-key",
    timeoutMargin: 400

//Main function
exports.handler = thundraWrapper((event, context, callback) => {
    callback(null, {msg: "Hello Thundra"});

Configuration via AWS console

This allows you to set Thundra’s environment variables in your AWS lambda function console itself, after uploading your function using any of the methods of deployment. Hence allowing you to set them through AWS.

One of the ways to get your Lambda function onto the console is by uploading a zipped file. To do so, ensure that you have all the require node modules zipped in a single file. By choosing the ‘Upload a zip file’ option in the ‘Code entry type’ drop-down field of the console, you can upload your code with a few clicks, and begin to configure Thundra as you prefer.

Environment variables go in the ‘Environment Variables’ field of the console and clicking 'Save' on the top right-hand side will set your configurations.

You can configure Thundra using environment variables or module initialization parameters.
Environment variables have higher precedence over initialization parameters. For detailed information about all configuration options, check out this documentation.