Setting up native tracing for Java-based AWS Lambda functions
You can set up Instana AutoTrace for AWS Lambda functions written in Java and other languages based on Java virtual machine (JVM) like Kotlin. To set up native tracing for Java-based AWS Lambda functions, you need to add the Instana Lambda layer to your Lambda functions. After you enable tracing, you can view traces of all requests that are related to the Java-based AWS Lambda functions in the Instana UI.
- Supported runtimes
- Configuring the AWS Lambda function
- Optional: Configuring extra environment-based settings
Supported runtimes
Instana supports JVM 1.8 and above.
Configuring the AWS Lambda function
Ensure that you set up the Instana AWS agent for Lambda monitoring to collect versions and runtime metrics from inside the AWS Lambda runtime.
You can enable tracing of Lambda functions through the AWS web console or any of the following AWS management tools:
Enabling tracing through the AWS web console
To enable tracing of Lambda functions that are running inside a JVM, complete the following steps in the AWS Lambda UI:
-
Add the Instana Lambda layer to your function:
-
In the Configuration tab of your Lambda function, click Layers > Add a layer.
-
In the "Add layer to function" window, select Provide a layer version ARN, and copy and paste the Amazon Resource Name (ARN) for the Instana Lambda layer that matches your region. You can find the right ARN for the Instana Lambda layer in the Instana Lambda layers section.
-
Click Add.
-
-
Configure the following environment variables:
Environment variables Value JAVA_TOOL_OPTIONS
-javaagent:/opt/instana/standalone-collector.jar
INSTANA_ENDPOINT_URL
<serverless_instana_endpoint>
`INSTANA_AGENT_KEY
<your_instana_agent_key>
Make sure that you use the correct value for your region that starts with
https://serverless-
. For more information, see Endpoints for serverless monitoring.You can also obtain the correct values for these environment variables from your Instana UI. To obtain the correct values for these environment variables, click More > Agents > Install Agents > Platform: AWS > Technology: AWS Lambda in the Instana UI.
-
Save the Lambda function definition.
Enabling tracing through AWS command line interface
If you want to automate the Instana integration of your AWS Lambdas, see the following AWS CLI command example:
# Do not copy and paste this verbatim!
# It will overwrite any previously defined collection of layers and
# environment variables.
aws --region $YOUR_REGION lambda update-function-configuration \
--function-name $YOUR_LAMBDA_FUNCTION_NAME \
--layers $INSTANA_LAYER_ARN \
--environment ""Variables={JAVA_TOOL_OPTIONS=-javaagent:/opt/instana/standalone-collector.jar, INSTANA_ENDPOINT_URL=... , INSTANA_AGENT_KEY=... , ...}""
Instana Lambda layers
The ARNs of the latest version of the AWS Lambda layers for Java according to the region are as follows:
Region | ARN |
---|---|
af-south-1 |
arn:aws:lambda:ap-northeast-1:410797082306:layer:instana-java:81 |
ap-east-1 |
arn:aws:lambda:ap-east-1:410797082306:layer:instana-java:8 |
ap-northeast-1 |
arn:aws:lambda:ap-northeast-1:410797082306:layer:instana-java:81 |
ap-northeast-2 |
arn:aws:lambda:ap-northeast-2:410797082306:layer:instana-java:79 |
ap-northeast-3 |
arn:aws:lambda:ap-northeast-3:410797082306:layer:instana-java:8 |
ap-south-1 |
arn:aws:lambda:ap-south-1:410797082306:layer:instana-java:79 |
ap-south-2 |
arn:aws:lambda:ap-south-2:410797082306:layer:instana-java:8 |
ap-southeast-1 |
arn:aws:lambda:ap-southeast-1:410797082306:layer:instana-java:79 |
ap-southeast-2 |
arn:aws:lambda:ap-southeast-2:410797082306:layer:instana-java:79 |
ap-southeast-3 |
arn:aws:lambda:ap-southeast-3:410797082306:layer:instana-java:8 |
ap-southeast-4 |
arn:aws:lambda:ap-southeast-4:410797082306:layer:instana-java:8 |
ca-central-1 |
arn:aws:lambda:ca-central-1:410797082306:layer:instana-java:79 |
`cn-north-1' | arn:aws-cn:lambda:cn-north-1:107998019096:layer:instana-java:8 |
`cn-northwest-1' | arn:aws-cn:lambda:cn-northwest-1:107998019096:layer:instana-java:8 |
eu-central-1 |
arn:aws:lambda:eu-central-1:410797082306:layer:instana-java:79 |
eu-central-2 |
arn:aws:lambda:eu-central-2:410797082306:layer:instana-java:8 |
eu-north-1 |
arn:aws:lambda:eu-north-1:410797082306:layer:instana-java:79 |
eu-south-1 |
arn:aws:lambda:eu-south-1:410797082306:layer:instana-java:8 |
eu-south-2 |
arn:aws:lambda:eu-south-2:410797082306:layer:instana-java:8 |
eu-west-1 |
arn:aws:lambda:eu-west-1:410797082306:layer:instana-java:79 |
eu-west-2 |
arn:aws:lambda:eu-west-2:410797082306:layer:instana-java:79 |
eu-west-3 |
arn:aws:lambda:eu-west-3:410797082306:layer:instana-java:79 |
il-central-1 |
arn:aws:lambda:il-central-1:410797082306:layer:instana-java:8 |
me-central-1 |
arn:aws:lambda:me-central-1:410797082306:layer:instana-java:8 |
me-south-1 |
arn:aws:lambda:me-south-1:410797082306:layer:instana-java:8 |
sa-east-1 |
arn:aws:lambda:sa-east-1:410797082306:layer:instana-java:79 |
us-east-1 |
arn:aws:lambda:us-east-1:410797082306:layer:instana-java:79 |
us-east-2 |
arn:aws:lambda:us-east-2:410797082306:layer:instana-java:79 |
us-west-1 |
arn:aws:lambda:us-west-1:410797082306:layer:instana-java:79 |
us-west-2 |
arn:aws:lambda:us-west-2:410797082306:layer:instana-java:79 |
The pattern is arn:aws:lambda:${region}:410797082306:layer:instana-java:${layer-version}
(or arn:aws-cn:lambda:${region}:107998019096:layer:instana-java:${layer-version}
for AWS regions in China).
Make sure that you always use the latest versions of the Instana Lambda layer. Update the layer version that you use at regular intervals to benefit from features and fixes that are provided by the new version of the layer.
Optional: Configuring extra environment-based settings
For more information about the environment-based settings for Instana Lambda tracers, see the Configuring extra settings for the Instana Lambda tracers.