Monitoring AWS Lambda
Monitoring AWS Lambda requires installing the Instana AWS agent in the AWS environment and integrating the Instana Lambda tracers with AWS Lambda functions. After you install the Instana AWS agent (also called AWS sensor), you can view metrics
that are related to the AWS Lambda in the Instana UI. To view the Lambda traces in the Instana UI, you need to add an Instana Lambda tracer to your AWS Lambda function.
The Instana AWS agent is installed once per AWS account and region, and it monitors all the AWS Lambda functions in that account and region, along with other AWS services. For more information, see Monitoring Amazon Web Services (AWS) with Amazon Web Services (AWS) agent. This AWS agent or sensor collects infrastructure metrics for your AWS Lambda functions. You also need to add an Instana Lambda tracer to your AWS Lambda function to collect traces from the function. Depending on the Lambda function runtime, the tracer is installed as a layer in the AWS Lambda function or instrumented manually.
- Supported runtimes
- Configuring AWS Lambda monitoring
- Viewing Lambda function configurations, metrics, versions, and triggers
- Enabling alerts for cold starting or timeouts
- Using Lambda extension
- Performance and runtime considerations for Lambda monitoring
The AWS sensor for Lambda monitoring collects version details and metrics for all your Lambda functions, irrespective of the runtime.
AWS Lambda native tracing
AWS Lambda native tracing is available for the following runtimes:
- Go 1.x using Go 1.8 or later
- Java 8 (
java8.al2) and Java 11 (
- Node.js 18.x, 16.x, 14.x, 12.x, and 10.x
- Python 3.9, 3.8, and 3.7
- Ruby 2.7
Configuring AWS Lambda monitoring
To monitor AWS Lambda functions with Instana, complete the following steps:
- Configure the AWS sensor for Lambda monitoring.
- Install the Instana Lambda tracer in your Lambda function.
- Optional: Configure extra settings for the Instana Lambda tracers.
Configuring the AWS sensor for Lambda monitoring
To configure the AWS sensor, complete the following steps:
- Set up the AWS agent for AWS Lambda monitoring.
- If required, use proxy configuration.
For more information, see Configuring the AWS sensor for Lambda monitoring.
Installing Instana Lambda tracers in AWS Lambda functions
To capture tracing data (request-level data) and send to the Instana backend, you need to install runtime-specific Instana Lambda tracers in AWS Lambda functions. To install Instana Lambda tracers in AWS Lambda functions, see the installation instructions for the following runtimes:
Optional: Configuring extra settings for the Instana Lambda tracers
You can configure the optional environment variables that are generally supported in native Lambda tracing as outlined in the following table:
Note: Do not set the
INSTANA_DISABLE_CA_CHECK variable to
true unless you use Instana on premises and are unable to operate the Instana backend with a certificate with a known root
certificate authority (CA). If you enable this variable, your Lambda is vulnerable to Man in the Middle (MITM) attacks for this connection.
||Set timeout for the HTTP requests that report data to the Instana backend.|
||Set this variable to
||Set this variable to a semicolon-separated list of HTTP header names (for trigger types API gateway with Lambda proxy integration or application load balancer) to capture HTTP headers.|
||Define the custom service name.|
||Set the log level for the Instana package. Possible values are
||Set this variable to any value to set the log level to
||Set this variable to
Viewing Lambda function configurations, metrics, versions, and triggers
You can view all information about your Lambda functions through Instana.
To view the HTTP attributes, triggers, and metrics and version details for Lambda functions, complete the following steps:
- In the sidebar of the Instana UI, select Infrastructure.
- Click a specific monitored Lambda function.
You can see a host dashboard with all the collected metrics and Lambda versions. For more information, see Lambda configurations, metrics, versions, and triggers.
Enabling alerts for cold starting or timeouts
You can configure Smart Alerts for excessive cold starts or timeouts on your Lambda functions. To configure a Smart Alert, go to the Application perspective documentation that contains the Lambda functions you want an alert on, and add a Smart Alert:
- From the navigation panel in the Instana UI, click Applications.
- Select your application.
- Click Add Smart Alert.
- Click Switch to Advanced Mode.
- In the Select Services/Endpoints field in the Scope section, add one of the following filters:
Cloud Function As A Service > Cold Start is true
Cloud Function As A Service > Suspected Timeout is true
- In the Selected blueprint field in the Trigger section, select Throughput.
- In the threshold section, select a threshold value that fits your use case. Use 1 to include every occurrence or a higher value to have the rule violated on a particular number of cold starts or timeouts.
- Use the Time Threshold settings to fine-tune the alerting behavior.
Using Lambda extension
NodeJS layer version 71 and later include a Lambda extension.
This extension can improve performance of monitored Lambda functions by separating the process of sending data to the Instana backend from other Lambda function processes. To take advantage of these performance improvements, upgrade the Instana layer to a version that includes the extension.
Internally, the extension works with the language library to buffer and proxy all the requests to the Instana backend. Under normal operation, the extension does not extend the lifetime of the Lambda function. The lifetime is extended only during the following instances:
- A shutdown request to ensure all data that is held in the buffer to the backend is cleared.
- A situation when the Lambda function fails and stops sending spans. Wait for 3 seconds to see whether the root span is sent before you wait for the next invocation.
To disable the use of the extension, set the
INSTANA_DISABLE_LAMBDA_EXTENSION variable to
TRUE in your function's environment.
Performance and runtime considerations for Lambda monitoring
Adding Instana's Lambda monitoring increases the size of your deployed Lambda function. The additional size depends on the language-specific layer or library. To get the size of a particular Instana Lambda layer version, use the following shell commands:
aws lambda get-layer-version --layer-name <layer_arn> --version-number <target_version> | jq .Content.Location | xargs -L 1 curl --output layer.zip
unzip -l layer.zip
When you monitor a Lambda function with Instana, the performance impact is primarily driven by the time that is taken for the Lambda function to communicate with the Instana backend. At the end of each execution, the Instana-provided library makes a blocking call to either Instana AWS Lambda extension or your Instana tenant unit to report the result of the execution.
For functions that use the Lambda extension, this process takes place in the background and allows the monitored function to return its response as soon as the monitored code is ready.
For functions that are not using the Lambda extension, this process allows the reporting of the result of the execution only if the data is sent to your tenant unit.