Send data from AWS to Axiom using AWS Distro for OpenTelemetry
This page explains how to auto-instrument AWS Lambda functions and send telemetry data to Axiom using AWS Distro for OpenTelemetry.
This page explains how to auto-instrument and monitor applications running on AWS Lambda using the AWS Distro for OpenTelemetry (ADOT). ADOT is an OpenTelemetry collector layer managed by and optimized for AWS.
Alternatively, you can use the Axiom Lambda Extension to send Lambda function logs and platform events to Axiom. For more information, see AWS Lambda.
Axiom detects the extension and provides you with quick filters and a dashboard. For more information on how this enriches your Axiom organization, see AWS Lambda app.
ADOT Lambda collector layer
AWS Distro for OpenTelemetry Lambda provides a plug-and-play user experience by automatically instrumenting a Lambda function. It packages OpenTelemetry together with an out-of-the-box configuration for AWS Lambda and OTLP in an easy-to-setup layer. You can turn on and off OpenTelemetry for your Lambda function without changing your code.
With the ADOT collector layer, you can send telemetry data to Axiom with a simple configuration.
To determine the best method to send data from different AWS services, see Send data from AWS to Axiom.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to update the dataset you have created.
Set up ADOT Lambda layer
This example creates a new Lambda function and applies the ADOT Lambda layer to it with the proper configuration.
You can deploy your Lambda function with the choice of your runtime. This example uses the Python3.10 runtime.
Create a new Lambda function
Create a new Lambda function with the following content. For more information on creating Lambda functions, see the AWS documentation.
Add the ADOT Lambda layer
Add a new ADOT Lambda layer to your function with the following ARN (Amazon Resource Name). For more information on adding layers to your function, see the AWS documentation.
- Replace
AWS_REGION
with the AWS Region to send the request to. For example,us-west-1
. - Replace
ARCH
with the system architecture type. For example,arm64
. - Replace
VERSION
with the latest version number specified in the AWS documentation. For example,ver-1-25-0:1
.
Create the collector configuration file
The configuration file is a YAML file that contains the configuration for the OpenTelemetry collector. Create the configuration file /var/task/collector.yaml
with the following content. This tells the collector to receive telemetry data from the OTLP receiver and export it to Axiom.
- Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. - Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Set environment variables
Set the following environment variables. For more information on setting environment variables, see the AWS documentation.
AWS_LAMBDA_EXEC_WRAPPER
wraps the function handler with the OpenTelemetry Lambda wrapper. This layer enables the auto-instrumentation for your Lambda function by initializing the OpenTelemetry agent and handling the lifecycle of spans.OPENTELEMETRY_COLLECTOR_CONFIG_FILE
specified the location of the collector configuration file.
Run your function and observe telemetry data in Axiom
As the app runs, it sends traces to Axiom. To view the traces:
- In Axiom, click the Stream tab.
- Click your dataset.
Was this page helpful?