Docs » Instrument serverless functions for Splunk Observability Cloud » Instrument AWS Lambda functions for Splunk Observability Cloud » Instrument your AWS Lambda function for Splunk Observability Cloud » Instrument your AWS Lambda function using separate layers

Instrument your AWS Lambda function using separate layers ๐Ÿ”—

You can automatically instrument your AWS Lambda function for Splunk Observability Cloud using layers only for your runtime or language. Instrumenting your function using separate layers can significantly reduce overhead.

Follow these instructions to install the Splunk OpenTelemetry Lambda layer for Java, Python, or Node.js functions. See Instrument your AWS Lambda function for Splunk Observability Cloud for the all-in-one default deployment instructions.

Check compatibility and requirements ๐Ÿ”—

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.

Considerations on sizing and scaling ๐Ÿ”—

If you need to reduce performance overhead further, consider using the Collector in a separate EC2 instance instead rather than a layer. See Instrument your AWS Lambda function using a Collector gateway in EC2.

Install the AWS Lambda layer for your language ๐Ÿ”—

Follow these steps to instrument your function using the Splunk OpenTelemetry Lambda layer:

  1. In the AWS Lambda console, select the function that you want to instrument.

  2. In the Layers section, select Add a layer, then select Specify an ARN.

  3. 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 Java Layer</h3>
    
    <pre>
    arn:aws:lambda:us-east-2:254067382080:layer:splunk-apm-java:170
    arn:aws:lambda:us-east-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:eu-central-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:us-west-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:us-west-2:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-south-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-northeast-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-northeast-2:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-southeast-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-southeast-2:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ca-central-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:eu-west-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:eu-west-2:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:eu-west-3:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:eu-north-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:sa-east-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:eu-south-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-northeast-3:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:ap-east-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:af-south-1:254067382080:layer:splunk-apm-java:12
    arn:aws:lambda:me-south-1:254067382080:layer:splunk-apm-java:12
    </pre>
    
  4. Paste the selected ARN in the Specify an ARN field and select Add.

  5. Check that the Splunk layer appears in the Layers table.

  6. Repeat the previous steps to install 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.

    <h3>Splunk OpenTelemetry Lambda Collector Layer</h3>
    
    <pre>
    arn:aws:lambda:us-east-2:254067382080:layer:splunk-apm-collector:170
    arn:aws:lambda:us-east-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:eu-central-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:us-west-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:us-west-2:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-south-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-northeast-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-northeast-2:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-southeast-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-southeast-2:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ca-central-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:eu-west-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:eu-west-2:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:eu-west-3:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:eu-north-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:sa-east-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:eu-south-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-northeast-3:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:ap-east-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:af-south-1:254067382080:layer:splunk-apm-collector:12
    arn:aws:lambda:me-south-1:254067382080:layer:splunk-apm-collector:12
    </pre>
    
  7. (Optional) Repeat the previous steps to install AWS Lambda metrics extension layer for Splunk Infrastructure Monitoring.

    <h3>Splunk Metrics Extension Layer</h3>
    
    <pre>
    arn:aws:lambda:us-east-2:254067382080:layer:splunk-lambda-metrics:170
    arn:aws:lambda:us-east-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:eu-central-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:us-west-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:us-west-2:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-south-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-northeast-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-northeast-2:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-southeast-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-southeast-2:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ca-central-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:eu-west-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:eu-west-2:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:eu-west-3:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:eu-north-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:sa-east-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:eu-south-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-northeast-3:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:ap-east-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:af-south-1:254067382080:layer:splunk-lambda-metrics:12
    arn:aws:lambda:me-south-1:254067382080:layer:splunk-lambda-metrics:12
    </pre>
    

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:

  1. In the AWS Lambda console, open the function that you are instrumenting.

  2. Navigate to Configuration, then Environment variables.

  3. Select Edit.

  4. 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.

    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>.

  5. 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 value http/protobuf

  • OTEL_EXPORTER_OTLP_TRACES_ENDPOINT with the value https://ingest.<realm>.signalfx.com/v2/trace/otlp, substituting <realm> with the name of your organizationโ€™s realm.

Check that data appears in Splunk Observability Cloud ๐Ÿ”—

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.

This page was last updated on Dec 09, 2024.