Instrument your AWS Lambda function for Splunk Observability Cloud 🔗
Use the Splunk OpenTelemetry Lambda layer to automatically instrument your AWS Lambda functions for many programming languages. To get started, use the guided setup or follow the instructions manually.
To generate a template that instruments your AWS Lambda function using the Splunk OpenTelemetry Lambda layer, use the AWS Lambda guided setup. To access the AWS Lambda guided setup, follow these steps:
Log in to Splunk Observability Cloud.
Open the AWS Lambda guided setup . Optionally, you can navigate to the guided setup on your own:
In the navigation menu, select
.Go to the Available integrations tab, or select Add Integration in the Deployed integrations tab.
In the integration filter menu, select All.
In the Search field, search for AWS Lambda.
Select the AWS Lambda tile to open the AWS Lambda guided setup.
If you don’t use the guided setup, follow these instructions to manually install the Splunk OpenTelemetry Lambda layer.
The Splunk OpenTelemetry Lambda layer supports the following runtimes in AWS Lambda:
Java 8.al2, 11, 17, and 21
Python 3.8 and higher
Node.js 14 and higher
Go 1.21
The AWS Lambda layer requires 90 MB on-disk in standard x86_64 systems.
For more information, search for Lambda runtimes and other system requirements on the AWS documentation website.
The default version of the layer supports multiple runtimes and includes the Collector, as well as the metrics extension layer. If you need to reduce performance overhead, consider choosing from the following deployment methods:
Follow these steps to instrument your function using the Splunk OpenTelemetry Lambda layer:
In the AWS Lambda console, select the function that you want to instrument.
In the Layers section, select Add a layer, then select Specify an ARN.
Copy the Amazon Resource Name (ARN) for the region of your AWS Lambda function from the list that matches your architecture:
<h3>Splunk OpenTelemetry Lambda Layer</h3> <pre> arn:aws:lambda:us-east-2:254067382080:layer:splunk-apm:737 arn:aws:lambda:us-east-1:254067382080:layer:splunk-apm:109 arn:aws:lambda:eu-central-1:254067382080:layer:splunk-apm:109 arn:aws:lambda:us-west-1:254067382080:layer:splunk-apm:109 arn:aws:lambda:us-west-2:254067382080:layer:splunk-apm:109 arn:aws:lambda:ap-south-1:254067382080:layer:splunk-apm:108 arn:aws:lambda:ap-northeast-1:254067382080:layer:splunk-apm:108 arn:aws:lambda:ap-northeast-2:254067382080:layer:splunk-apm:108 arn:aws:lambda:ap-southeast-1:254067382080:layer:splunk-apm:108 arn:aws:lambda:ap-southeast-2:254067382080:layer:splunk-apm:107 arn:aws:lambda:ca-central-1:254067382080:layer:splunk-apm:107 arn:aws:lambda:eu-west-1:254067382080:layer:splunk-apm:107 arn:aws:lambda:eu-west-2:254067382080:layer:splunk-apm:107 arn:aws:lambda:eu-west-3:254067382080:layer:splunk-apm:107 arn:aws:lambda:eu-north-1:254067382080:layer:splunk-apm:107 arn:aws:lambda:sa-east-1:254067382080:layer:splunk-apm:107 arn:aws:lambda:eu-south-1:254067382080:layer:splunk-apm:54 arn:aws:lambda:ap-northeast-3:254067382080:layer:splunk-apm:54 arn:aws:lambda:ap-east-1:254067382080:layer:splunk-apm:54 arn:aws:lambda:af-south-1:254067382080:layer:splunk-apm:54 arn:aws:lambda:me-south-1:254067382080:layer:splunk-apm:54 </pre>
<h3>Splunk OpenTelemetry Lambda Layer (arm64)</h3> <pre> arn:aws:lambda:us-east-2:254067382080:layer:splunk-apm-arm:58 arn:aws:lambda:us-east-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:eu-central-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:us-west-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:us-west-2:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-south-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-northeast-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-northeast-2:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-southeast-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-southeast-2:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ca-central-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:eu-west-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:eu-west-2:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:eu-west-3:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:eu-north-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:sa-east-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:eu-south-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-northeast-3:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:ap-east-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:af-south-1:254067382080:layer:splunk-apm-arm:38 arn:aws:lambda:me-south-1:254067382080:layer:splunk-apm-arm:38 </pre>
Paste the selected ARN in the Specify an ARN field and select Add.
Check that the Splunk OpenTelemetry Lambda layer appears in the Layers table.
If you don’t want to use a local Collector, you must specify the address of a Collector in data forwarding mode. See Set up a Collector gateway in EC2.
Note
You can automate the update of the AWS Lambda layers using the AWS CLI or other automation tools.
Configure the Splunk OpenTelemetry Lambda layer 🔗
Follow these steps to add the required configuration for the Splunk OpenTelemetry Lambda layer:
In the AWS Lambda console, open the function that you are instrumenting.
Navigate to Configuration, then Environment variables.
Select Edit.
Add each of the following environment variables by selecting Add environment variable:
Environment variable
Description
SPLUNK_REALM
To find your Splunk realm, see Note about realms.
SPLUNK_ACCESS_TOKEN
A Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. See Authentication token. To send data to a Splunk OTel Collector in EC2, see Set up a Collector gateway in EC2.
AWS_LAMBDA_EXEC_WRAPPER
Set the value for the environment variable given your programming language:
# Select the most appropriate value # Wraps regular handlers that implement RequestHandler /opt/otel-handler # Same as otel-handler, but proxied through API Gateway, # with HTTP context propagation activated /opt/otel-proxy-handler # Wraps streaming handlers that implement RequestStreamHandler /opt/otel-stream-handler
Note
Only AWS SDK v2 instrumentation is activated by default. To instrument other libraries, modify your code to include the corresponding library instrumentation from the OpenTelemetry Java SDK.
/opt/otel-instrument
/opt/nodejs-otel-handler
OTEL_SERVICE_NAME
The name of your service.
(Optional)
OTEL_RESOURCE_ATTRIBUTES
Define the name of the deployment environment of your function by setting this environment variable to
deployment.environment=<name-of-your-environment>
.Select Save and check that the environment variables appear in the table.
To configure the mode of metric ingest, see Metrics configuration.
Note
By default, the layer sends telemetry to a Collector instance on localhost using the Collector layer. If you don’t want to use a local Collector, you must specify the address of a Collector in data forwarding mode. See Set up a Collector gateway in EC2.
Send spans directly to Splunk Observability Cloud 🔗
By default, the Splunk OpenTelemetry Lambda layer sends telemetry to a Collector instance running alongside AWS Lambda.
To send spans directly to Splunk Observability Cloud from an AWS Lambda function instrumented using the Splunk OpenTelemetry Lambda layer add the following environment variables:
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
with the valuehttp/protobuf
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
with the valuehttps://ingest.<realm>.signalfx.com/v2/trace/otlp
, substituting<realm>
with the name of your organization’s realm.
Each time the AWS Lambda function runs, trace and metric data appears in Splunk Observability Cloud. If no data appears, see Troubleshoot the Splunk OpenTelemetry Lambda layer.