SigNoz Cloud - This page is relevant for SigNoz Cloud editions.
Self-Host - This page is relevant for self-hosted SigNoz editions.

Send logs from AWS Lambda Node.js functions to SigNoz

This guide walks through instrumenting your AWS Lambda Node.js function to emit structured logs to SigNoz using the OpenTelemetry SDK. You will add the OTel Lambda Layer and call logger.emit directly in your code for fine-grained, attribute-rich log records.

💡 Tip

OTel Collector Extension Layer: For a code-free approach to collect logs, use the OTel Collector Extension Layer.

AWS Lambda Logs via S3: Prefer routing logs via CloudWatch Logs and S3? Use AWS Lambda Logs via S3 for a code-free approach to collect logs.

Prerequisites

  • An AWS account with permissions to create and manage Lambda functions.
  • A SigNoz account (Cloud or Self-Hosted).

Steps

Step 1: Add Required Dependencies

Add the necessary OpenTelemetry packages to your Node.js project.

yarn add @opentelemetry/api @opentelemetry/api-logs

Step 2: Instrument Your Lambda Function

Update your Lambda function code to initialize the logger provider and send logs.

index.js
const { trace } = require("@opentelemetry/api");
const logsAPI = require("@opentelemetry/api-logs");

// Initialize Logger Provider
const provider = logsAPI.logs.getLoggerProvider();
const logger = provider.getLogger("default", "1.0.0");

const tracer = trace.getTracer("default", "1.0.0");

exports.handler = async (event) => {
  const parentSpan = tracer.startSpan("main");

  // Example of creating a span and emitting a log within it
  tracer.startActiveSpan("process-request", (span) => {
    logger.emit({
      severityText: "INFO",
      body: "Processing request in Lambda",
      attributes: { "custom.attribute": "value" },
    });
    span.end();
  });

  const response = {
    statusCode: 200,
    body: JSON.stringify("Hello from SigNoz Lambda!"),
  };

  // IMPORTANT: Flush logs before the function exits
  await provider.forceFlush();
  parentSpan.end();

  return response;
};

Key Points:

  • logger.emit: Used to send structured logs.
  • provider.forceFlush(): Critical to ensure logs are sent before the Lambda environment freezes or shuts down.

Step 3: Create Deployment Package

Zip your function code and dependencies.

zip -r deploy.zip .

Step 4: Upload to AWS Lambda

  1. Navigate to your function in the AWS Console.
  2. Go to the Code tab.
  3. Choose Upload from -> .zip file and upload your deploy.zip.

Step 5: Configure Environment Variables

Navigate to Configuration > Environment Variables and add the following:

AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<region>.signoz.cloud:443
OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=<SIGNOZ_INGESTION_KEY>
OTEL_SERVICE_NAME=<service_name>

Verify these values:

  • <region>: Your SigNoz Cloud region.
  • <SIGNOZ_INGESTION_KEY>: Your SigNoz Ingestion Key.
  • <service_name>: A name for your Lambda service (e.g., my-lambda-service).

Step 6: Add OpenTelemetry Lambda Layer

This layer provides the OpenTelemetry Node.js Extension for AWS Lambda with auto-instrumentation capabilities.

  1. Go to the Layers section of your function.
  2. Click Add a layer.
  3. Select Specify an ARN.
  4. Enter the ARN for your region and architecture. Find the latest ARN on the opentelemetry-lambda releases page.

Example ARN (Node.js, x86_64, us-east-1):

arn:aws:lambda:us-east-1:184161586896:layer:opentelemetry-nodejs-0_20_0:1

Validate

  1. Trigger your Lambda function (e.g., using a Test event in the AWS Console).
  2. Go to the SigNoz Logs Explorer.
  3. Filter by service.name.
  4. You should see your structured log records with the custom attributes you set (e.g., custom.attribute).

Troubleshooting

Logs not appearing in SigNoz

  • Check endpoint and key: Verify OTEL_EXPORTER_OTLP_ENDPOINT points to the correct SigNoz region and that OTEL_EXPORTER_OTLP_HEADERS contains a valid ingestion key.
  • Check CloudWatch: Open CloudWatch Logs for your Lambda function and look for OTel SDK output. Errors here usually indicate a misconfigured endpoint or a missing/wrong ingestion key.
  • Check layer version: Ensure the OTel Lambda layer ARN matches your function's runtime and architecture.

Logs missing attributes

  • Confirm you are passing a resource with service.name when initialising the SDK.
  • Verify OTEL_SERVICE_NAME is set if you rely on the environment variable instead of a code-level resource.

"Task timed out" error

  • Increase your Lambda function's timeout (e.g., to 30 seconds) to allow the SDK time to flush spans and logs before the function exits.

Get Help

If you need help with the steps in this topic, please reach out to us on SigNoz Community Slack.

If you are a SigNoz Cloud user, please use in product chat support located at the bottom right corner of your SigNoz instance or contact us at cloud-support@signoz.io.

Last updated: March 26, 2026

Edit on GitHub

Was this page helpful?

Your response helps us improve this page.