To configure APM through the AWS Management Console:
-
Navigate to your function in the AWS Management Console
-
Click on the Configuration tab
-
Click on Environment variables
-
Add the following required variables:
AWS_LAMBDA_EXEC_WRAPPER = /opt/python/bin/elasticapm-lambda # use this exact fixed value
ELASTIC_APM_LAMBDA_APM_SERVER = <YOUR-APM-SERVER-URL> # this is your APM Server URL
ELASTIC_APM_SECRET_TOKEN = <YOUR-APM-SECRET-TOKEN> # this is your APM secret token
ELASTIC_APM_SEND_STRATEGY = background (1)To configure APM through the AWS command line interface execute the following command:
aws lambda update-function-configuration --function-name yourLambdaFunctionName \
--environment "Variables={AWS_LAMBDA_EXEC_WRAPPER=/opt/python/bin/elasticapm-lambda,ELASTIC_APM_LAMBDA_APM_SERVER=<YOUR-APM-SERVER-URL>,ELASTIC_APM_SECRET_TOKEN=<YOUR-APM-SECRET-TOKEN>,ELASTIC_APM_SEND_STRATEGY=background}" (1)In your SAM template.yml file configure the following environment variables:
...
Resources:
yourLambdaFunction:
Type: AWS::Serverless::Function
Properties:
...
Environment:
Variables:
AWS_LAMBDA_EXEC_WRAPPER: /opt/python/bin/elasticapm-lambda
ELASTIC_APM_LAMBDA_APM_SERVER: <YOUR-APM-SERVER-URL>
ELASTIC_APM_SECRET_TOKEN: <YOUR-APM-SECRET-TOKEN>
ELASTIC_APM_SEND_STRATEGY: background (1)
...In your serverless.yml file configure the following environment variables:
...
functions:
yourLambdaFunction:
...
environment:
AWS_LAMBDA_EXEC_WRAPPER: /opt/python/bin/elasticapm-lambda
ELASTIC_APM_LAMBDA_APM_SERVER: <YOUR-APM-SERVER-URL>
ELASTIC_APM_SECRET_TOKEN: <YOUR-APM-SECRET-TOKEN>
ELASTIC_APM_SEND_STRATEGY: background (1)
...In your Terraform file configure the following environment variables:
...
resource "aws_lambda_function" "your_lambda_function" {
...
environment {
variables = {
AWS_LAMBDA_EXEC_WRAPPER = /opt/python/bin/elasticapm-lambda
ELASTIC_APM_LAMBDA_APM_SERVER = "<YOUR-APM-SERVER-URL>"
ELASTIC_APM_SECRET_TOKEN = "<YOUR-APM-SECRET-TOKEN>"
ELASTIC_APM_SEND_STRATEGY = "background" (1)
}
}
}
...Environment variables configured for an AWS Lambda function are passed to the container running the lambda function. You can use one of the other options (through AWS Web Console, AWS CLI, etc.) to configure the following environment variables:
AWS_LAMBDA_EXEC_WRAPPER = /opt/python/bin/elasticapm-lambda # use this exact fixed value
ELASTIC_APM_LAMBDA_APM_SERVER = <YOUR-APM-SERVER-URL> # this is your APM Server URL
ELASTIC_APM_SECRET_TOKEN = <YOUR-APM-SECRET-TOKEN> # this is your APM secret token
ELASTIC_APM_SEND_STRATEGY = background (1)