AWS Lambda Node.js — Zero-Code Instrumentation with Elven Observability Layer

Overview

Elven provides instrumentation Layers for AWS Lambda, enabling:

  • Automatic collection of logs, metrics, and traces.

  • Data forwarding to the Elven Observability platform with zero code.

  • Fully managed via Layers and environment variables.

  • Compatible with any Lambda runtime language through our universal bootstrap.

This documentation describes how to instrument your Lambda using the official Elven Layers.

Prerequisites

  • The Lambda function must already be implemented and functional.

  • Permission to modify the Lambda configuration (Layers and environment variables).

  • Have the Tenant ID and authentication Token provided by Elven Observability.

If you do not have the Tenant ID and Token, access:

https://elvenobservability.com

Or request it from the Elven support team.

Configuring the Lambda

Step 1 — Add the Elven Layer

Choose the Layer according to your case:

Layer
ARN

elven-instrumentation-js (complete: logs + metrics + traces)

(use the list of ARNs below)

Example (us-east-1):

arn:aws:lambda:us-east-1:204595508824:layer:elven-instrumentation-js:1
  • In the AWS Lambda console, go to your function > Configuration > Layers > Add a layer.

  • Add the Layer using the ARN for your region.

Step 2 — Modify the Handler

Very important: By default, the Elven Layer intercepts the Lambda execution through its own bootstrap.

You must:

Set the actual path of your handler in the AWS_LAMBDA_FUNCTION_HANDLER environment variable.

Example:

AWS_LAMBDA_FUNCTION_HANDLER=src/index.handler

Set the Elven bootstrap:

In the console, add:

AWS_LAMBDA_EXEC_WRAPPER=/opt/bootstrap

This ensures that the Elven bootstrap initializes first, before calling your actual handler.

Step 3 — Configure the environment variables

Below is the complete list:

Variable
Description
Example

AWS_LAMBDA_FUNCTION_HANDLER

Actual path of your handler

src/index.handler

AWS_LAMBDA_EXEC_WRAPPER

Always /opt/bootstrap

/opt/bootstrap

LOKI_AUTH_TOKEN

Authentication token

(fornecido pela Elven)

LOKI_TENANT_ID

Client Tenant ID

(fornecido pela Elven)

LOKI_APP_NAME

Application name (for labeling)

my-app

LOKI_COOPERATIVE_MODE

Enable resilient mode

true

LOKI_PURE_HANDLER

Safe interception mode

true

LOKI_SAFE_INIT

Enable protected startup

true

OTEL_EXPORTER_OTLP_ENDPOINT

Endpoint of your OTEL Collector

OTEL_SERVICE_NAME

Service name (traces)

my-app

OTEL_RESOURCE_ATTRIBUTES

Additional resource attributes

service.name=my-app,environment=production

OTEL_LAMBDA_TRACE_MODE

Enable trace capture

capture

OTEL_LOG_LEVEL

Internal SDK log

error

OTEL_PROPAGATORS

Active propagators

tracecontext,baggage,xray

OTEL_TRACES_SAMPLER

Trace sampling

always_on

Important Note:

  • The LOKI_AUTH_TOKEN e LOKI_TENANT_ID variables are provided by Elven.

  • An active and accessible OpenTelemetry Collector is also required for sending traces and metrics (OTEL_EXPORTER_OTLP_ENDPOINT).

  • If you do not have the Token, Tenant ID, or Collector configured, please contact Elven Support.

Step 4 — Deploy

Now just save and deploy your Lambda.

Instrumentation will be automatic.

Practical examples

Fully functional example

Imagine your original Lambda configured with the handler:

Handler: src/index.handler

After instrumentation with Elven:

  • In the Lambda Handler field (AWS Console), you can enter anything — it doesn't matter.

  • Add:

AWS_LAMBDA_FUNCTION_HANDLER=src/index.handler
AWS_LAMBDA_EXEC_WRAPPER=/opt/bootstrap
# e todas as variáveis do bloco 3

Done. No code changes are required.

Common Issues & Troubleshooting

Problem
Cause
Solution

Cannot find handler.

AWS_LAMBDA_FUNCTION_HANDLER is not set correctly.

Check the exact handler path, including subfolders.

Initialization timeout.

Network failure when connecting to Loki/OTEL.

Check if your Lambda has access to the internet or private endpoints.

Data is not showing up in Elven.

Incorrect Token or Tenant.

Request new authentication data from support.

Support & Contact

If you need help with configuration, onboarding, or troubleshooting, please contact us:

📧 [email protected]

🌐 https://elvenobservability.com

Full Layer ARNs (by region)

  • us-east-1: arn:aws:lambda:us-east-1:204595508824:layer:elven-instrumentation-js:1

  • us-east-2: arn:aws:lambda:us-east-2:204595508824:layer:elven-instrumentation-js:1

  • us-west-1: arn:aws:lambda:us-west-1:204595508824:layer:elven-instrumentation-js:1

  • us-west-2: arn:aws:lambda:us-west-2:204595508824:layer:elven-instrumentation-js:1

  • sa-east-1: arn:aws:lambda:sa-east-1:204595508824:layer:elven-instrumentation-js:1

Last updated

Was this helpful?