Our next-gen architecture is built to help you make sense of your ever-growing data Watch a 4-min demo video!

Back to All Integrations

AWS Lambda Telemetry Exporter AWS Lambda Telemetry Exporter

Last Updated: Sep. 18, 2023

This tutorial demonstrates how to set up and install the Coralogix AWS Lambda Telemetry Exporter.

This integration is one of two options – complete and basic – for monitoring Lambda, a requirement our cutting-edge Serverless Monitoring feature.

  • This tutorial demonstrates how to set up Lambda monitoring to get basic telemetry, including logs, which requires setting up the Coralogix AWS Lambda Telemetry Exporter.
  • To set up Lambda monitoring to get complete telemetry, including traces, view the relevant documentation here.

Overview

The Coralogix AWS Lambda Telemetry Exporter is an AWS Lambda extension that uses AWS Lambda Telemetry API and seamlessly collects Lambda function logs, as well as Lambda platform logs, metrics, and traces. It is currently available as an open beta.

The Coralogix AWS Lambda Telemetry Exporter supersedes the previously offered Coralogix Extension for AWS Lambda (version 1.x.y) by extending its capabilities beyond logs. If you’re already using the Coralogix Extension for AWS Lambda, you can use it for now or migrate to the Telemetry Exporter to enjoy the new goodies early. We recommend using the Telemetry Exporter in new deployments.

This document assumes version 0.5.1 (layer version 21) of the Coralogix AWS Lambda Telemetry Exporter. If you’re using an older version, we highly recommend updating.

Setting up Lambda monitoring

In order to monitor AWS Lambda functions using Coralogix follow these steps. Each of the steps is described in it’s own document.

STEP 1. Set up Coralogix AWS Resource Metadata Collection

STEP 2a. To get full telemetry, including tracing, set up the AWS Lambda Auto-Instrumentation. This is available for Node.js and Python (3.8 or newer). For other runtimes choose Step 2b.

STEP 2b. Alternatively, to get logs and basic telemetry, set up just the Coralogix AWS Lambda Telemetry Exporter

STEP 3. Learn what the Serverless Monitoring feature has to offer.

The document you’re viewing now is for Step 2b. You may want to proceed with Step 2a instead.

Prerequisites

  • An active AWS account with permissions to manage Lambda functions.
  • At least one AWS Lambda function selected for monitoring

Setup

The Coralogix AWS Lambda Telemetry Exporter is available with any of the following:

  • Using ARN of a lambda layer published by Coralogix (recommended)
  • Copying the telemetry exporter into a container image (recommended for Docker)
  • Deploying your own copy of the lambda layer to your AWS account from AWS Serverless Repository

Installation: Published Layer ARN

To deploy or update the Coralogix AWS Lambda Telemetry Exporter, select the ARN corresponding to your AWS region and CPU architecture from the following list:

arn:aws:lambda:ap-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:eu-north-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-north-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:eu-west-3:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-west-3:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:eu-west-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-west-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:eu-west-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-west-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-northeast-3:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-northeast-3:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-northeast-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-northeast-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-northeast-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-northeast-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ca-central-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ca-central-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:sa-east-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:sa-east-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-southeast-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-southeast-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-southeast-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-southeast-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:eu-central-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-central-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:us-east-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:us-east-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:us-east-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:us-east-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:us-west-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:us-west-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:us-west-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:us-west-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:af-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:af-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-east-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-east-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-southeast-3:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-southeast-3:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:eu-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:me-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:me-south-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-arm64:21
arn:aws:lambda:ap-south-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:ap-southeast-4:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-central-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:eu-south-2:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:me-central-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21
arn:aws:lambda:il-central-1:625240141681:layer:coralogix-aws-lambda-telemetry-exporter-x86_64:21

STEP 1. Configure the coralogix-aws-lambda-telemetry-exporter.

  • Access the Lambda function that you would like to monitor and configure the environment variables: Configuration > Environment variables
  • View the list of configuration variables in the Configuration section below.

STEP 2. Add the Telemetry Exporter layer to the chosen function.

  • Access the Lambda function from which you want to send telemetry data to Coralogix: Layers > Add Layer> Specify an ARN > paste ARN from the list provided above > Add

Notes:

  • If you are unsure about the architecture, it is displayed under Function runtime settings.
  • If that function was already using coralogix-lambda-extension, we suggest removing it: Layers > Edit > Select the Lambda layer > Remove

Installation: Container Image Lambda

To deploy your lambda as a container image and inject an extension as part of your function, build from the exporter image found here.

FROM coralogixrepo/coralogix-aws-lambda-telemetry-exporter:0.5.1 AS coralogix-extension
FROM public.ecr.aws/lambda/python:3.8
# Layer code
WORKDIR /opt
COPY --from=coralogix-extension /opt/ .
# Function code
WORKDIR /var/task
COPY app.py .
CMD ["app.lambda_handler"]

In this example, python3.8 is being used as the runtime, but all runtimes are supported with our lambda extension.

Notes:

  • There is no latest tag for the coralogix-aws-lambda-telemetry-exporter image; you must specify the version explicitly.
  • Find information on available versions/tags here.

Configuration

  • CX_DOMAIN: Coralogix domain within which you’ve set up your account.
  • CX_PRIVATE_KEY: Coralogix Send Your Data – API Key.
  • CX_REPORTING_STRATEGY: Acceptable values include LOW_OVERHEAD, REPORT_AFTER_INVOCATION and REPORT_DURING_AND_AFTER_INVOCATION. For info on how to choose the optimal strategy for your Lambda function, see Reporting Strategies section below.
  • CX_APPLICATION & CX_SUBSYSTEM (optional): Defaults to AWS account number and Lambda function, respectively. Learn more about application and subsystem names on your Coralogix dashboard here.
  • CX_AWS_TELEMETRY_INTERVAL_MS (optional): Use this parameter to adjust how often AWS sends telemetry to the Telemetry Exporter. We recommend using this parameter only when necessary and otherwise relying on the default, which depends on the selected reporting strategy:
    • LOW_OVERHEAD > 10000
    • REPORT_AFTER_INVOCATION > 25
    • REPORT_DURING_AND_AFTER_INVOCATION > 2000
  • CX_LOG_METADATA_ENABLED (optional): Defaults to true. Set to false to exclude the cx_metadata from logs in order to reduce their size.
  • CX_OTLP_SERVER_ENABLED (optional): Defaults to true. Set to false to disable the OTLP server and free up the 4317 and 4318 ports.
  • CX_LOG_ONLY (optional): When set to true disables metrics and tracing.
  • CX_LOG_MODE (optional): Defaults to structured. Acceptable values are:
    • disabled – no logs will be delivered to coralogix
    • structured – logs will be wrapped in a JSON and delivered to coralogix
  • CX_METRICS_MODE (optional): Defaults to platform_report. Acceptable values are:
    • disabled – no metrics will be delivered to coralogix
    • platform_report – metrics based on AWS Telemetry API Platform Report event will be delivered to coralogix
  • CX_TRACING_MODE (optional): Defaults to telemetry_api. Acceptable values are:
    • disabled – no traces will be delivered to coralogix
    • telemetry_api – will generate spans basing on data provided by the AWS Lambda Telemetry API.
    • otel – will expect to receive spans from the function via OTLP. This mode is meant to be used in conjunction with OTEL instrumentation of the function and the CX_OTLP_SERVER_ENABLED enabled. Warning: otel tracing mode delays emitting logs until the end of the invocation even when reporting strategy is set to REPORT_DURING_AND_AFTER_INVOCATION .
  • CX_TRACE_SAMPLING_MODE (optional): Defaults to all. Acceptable values are:
    • all – all traces are sent to coralogix
    • follow_xray – the telemetry exporter will respect AWS XRay’s decision which traces should be sampled
  • CX_TAGS_ENABLED (optional): Defaults to false. Setting it to true will enable enrichment of the telemetry with the tags of the Lambda function. See Enrichment with tags section to learn how to correctly set this up.
  • CX_TAG_CACHE_VALIDITY_MS (optional): Defaults to 60000 (1 minute). Controls how often the tags will be refreshed.
  • CX_MESSAGE_SIZE_LIMIT (optional): Defaults to 30000. Log messages longer than CX_MESSAGE_SIZE_LIMIT bytes will be truncated.

Reporting Strategies

Due to the serverless nature of AWS Lambda and Lambda extensions, the telemetry-exporter cannot freely do its job after and between invocations of the monitored Lambda function. A tradeoff has to be made between timely delivery of the telemetry and keeping overhead costs low.

The optimal strategy choice depends on how often the Lambda function is invoked and how long it runs. The coralogix-aws-lambda-telemetry-exporter offers three reporting strategies that enable you to adjust reporting to the characteristics of your function.

  • LOW_OVERHEAD : Recommended for frequently called functions. Telemetry is batched across many invocations of the function, and the telemetry-exporter avoids keeping the Lambda execution environment active after an invocation is complete (and in turn avoids additional billable time to the invocations). This may result in long delays (in the order of minutes) in the delivery of telemetry.
  • REPORT_AFTER_INVOCATION : Recommended for rarely called functions with short to moderate execution times. Telemetry is reported at the end of each invocation, limiting the amount of billable time for each invocation.
  • REPORT_DURING_AND_AFTER_INVOCATION : Recommended for rarely called functions with long execution times (15s or more). Telemetry is reported in regular intervals during the execution of the function and then after the execution completes. This strategy will add 2-3s of billable time to each invocation.

Notes:

  • Regardless of the chosen reporting strategy, technical limitations may place constraints on delivery times for some telemetry data.
  • Rather than being delivered directly after invocation, some data (such as the total billable time of an invocation) is delivered during the next invocation of the Lambda function instance.

Using Metrics

Check out our tutorial here.

Enrichment with Tags

Coralogix AWS Lambda Telemetry Exporter can read the tags of the AWS Lambda function and add them to all reported telemetry (logs/metrics/traces). This feature is disabled by default and can be enabled with CX_TAGS_ENABLED, but it requires prior configuration of permissions for the Lambda function. The configuration can be done in the following steps:

STEP 1. In AWS Console access the Lambda function that you would like to configure and navigate to: Configuration > Permissions

STEP 2. Click on the name of the execution role. This will bring to the IAM configuration of that role.

STEP 3. Click Add Permissions > Create Inline Policy

STEP 4. Switch to JSON view and paste the following policy JSON:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "lambda:GetFunction",
            "Resource": "<paste lambda ARN here>"
        }
    ]
}

STEP 5. Replace the <paste lambda ARN here> with the ARN of the Lambda function. (you can find it on main page of the function’s configuration)

STEP 6. Click Review Policy

STEP 7. Name the policy, for example ListLambdaTags.

STEP 8. Click Create Policy.

STEP 9. Set the CX_TAGS_ENABLED environment variable to true.

PrivateLink

The Coralogix AWS Lambda Telemetry Exporter can send telemetry to Coralogix over AWS Private Link by implementing the following steps:

STEP 1. Set up PrivateLink for your VPC.

STEP 2. Configure the lambda function to run in that VPC.

STEP 3. Change the CX_DOMAIN environment variable, by adding private. at the beginning. For example, if your CX_DOMAIN used to be coralogix.com , now it should appear as private.coralogix.com.

Code Signing

The Coralogix AWS Lambda Telemetry Exporter Lambda layers are signed with arn:aws:signer:eu-west-1:625240141681:/signing-profiles/coralogix_lambda AWS Signer profile. You may need to add this profile to your code signing configuration if you have configured Lambda to require signed code.

Update Coralogix AWS Lambda Telemetry Exporter

💡 Version 0.4.x (or newer) uses different operation, and therefore requires different permissions to obtain tags. If you’ve configured the lambda:ListTags for version 0.3.x, you should change it to lambda:GetFunction when upgrading to 0.4.x.

💡 Version 0.4.x (or newer) uses different default value for CX_TAG_CACHE_VALIDITY_MS. Previously the default was 60000 (1 minute); now it’s 300000 (5 minutes).

💡 Version 0.3.x (or newer) accepts environment variables starting CX_ or CORALOGIX_ prefixes. We recommend using the CX_ prefix to reduce the size of environment variables. This may be significant as AWS puts a 4kB limit on the total size of environment variables of a function.

💡 Version 0.3.x (or newer) reports response latency/duration as tags (attributes) of the invocation span instead of reporting it as independent spans. This change has been made to declutter the trace.

💡 Version 0.2.x (or newer) introduces changes in log structure. You may need to adjust your queries, filters or parsing rules to work with the new log structure.

Update the Procedure for ARN-Based Installations

STEP 1. Look up the latest layer version by the reviewing the list of ARNs presented earlier. The number at the end of the ARN is the layer version.

STEP 2. Change the Telemetry Exporter layer version used by the function: Layers > Edit > Change to the updated layer version > Save

Update the Procedure for AWS Serverless Repository-Based Installations

STEP 1. Deploy the Coralogix-AWS-Lambda-Telemetry-Exporter in your AWS Serverless Application Repository. You are required to deploy it in the same account and region as your Lambda function.

STEP 2. Verify the deployment by clicking on ‘Layers’ in the left-hand menu. You should see that the two previously deployed Lambda layers have new versions. Keep in mind that the version number of the Lambda layer is simply incremented with each deployment and does not correspond to the semantic version shown in the AWS Serverless repository.

STEP 3. Change the Telemetry Exporter layer version used by the function: Layers > Edit > Change to latest available layer version > Save

Additional Resources

DocumentationAWS Lambda Auto Instrumentation
Severless Monitoring

Support

Need help?

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us via our in-app chat or by sending us an email at [email protected].

On this page