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

Generate customized instructions using the guided setup

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:

  1. Log in to Splunk Observability Cloud.

  2. Open the AWS Lambda guided setup . Optionally, you can navigate to the guided setup on your own:

    1. In the navigation menu, select Data Management.

    2. Go to the Available integrations tab, or select Add Integration in the Deployed integrations tab.

    3. In the integration filter menu, select All.

    4. In the Search field, search for AWS Lambda.

    5. Select the AWS Lambda tile to open the AWS Lambda guided setup.

Install the Splunk OpenTelemetry Lambda layer manually

If you don’t use the guided setup, follow these instructions to manually install the Splunk OpenTelemetry Lambda layer.

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

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:

Install the all-in-one AWS Lambda layer

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

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

  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 May 08, 2024.