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

Coralogix Amazon Web Services (AWS) Lambda Telemetry Exporter Coralogix Amazon Web Services (AWS) Lambda Telemetry Exporter

Last Updated: Mar. 07, 2023

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 are already using the Coralogix Extension for AWS Lambda you can stick with it for now or migrate to the Telemetry Exporter to enjoy the new goodies early. We recommend using the Telemetry Exporter in new deployments.

Note! Coralogix AWS Lambda Telemetry Exporter version 0.2.0 introduces changes in log structure. You may need to adjust your queries, filters or parsing rules to work with the new log structure.

New! Coralogix AWS Lambda Telemetry Exporter version 0.2.0 now sends metrics.

Prerequisites

1. Sign up for a Coralogix account. Set up your account on the Coralogix domain corresponding to the region within which you would like your data stored.

2. Access your Coralogix private key.

3. Create an active AWS account with permissions to manage Lambda functions.

4. Choose at least one AWS Lambda function to monitor.

Setup

Installation

The Coralogix AWS Lambda Telemetry Exporter is available either by:

  • Using ARN of a lambda layer published by Coralogix (recommended)
  • Deploying your own copy of the lambda layer to your AWS account from AWS Serverless Repository

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

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

Configuration

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

Note: Prior to version 0.3.0, variables began with the CORALOGIX_ prefix. Version 0.3.0 accepts both CX_ and CORALOGIX_ prefixes. We recommend using the CX_ prefix to reduce the size of environment variables, as AWS puts a 4kB limit on the total size of environment variables of a function.

  • Input the environment variables below:
    • CX_DOMAIN: Coralogix domain within which you’ve set up your account.
    • CX_PRIVATE_KEY: Coralogix private 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 since 0.2.0): 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_METRICS_ENABLED (since 0.2.0) (optional): Defaults to true. Set to false to disable metrics reporting.
    • CX_LOG_METADATA_ENABLED (since 0.2.0) (optional): Defaults to true. Set to false to exclude the cx_metadata from logs in order to reduce their size.
    • CX_OTLP_SERVER_ENABLED (since 0.3.0) (optional): Defaults to true. Set to false to disable the OTLP server and free up the 4317 and 4318 ports.
    • CX_TRACING_MODE (since 0.3.0) (optional): Defaults to telemetry_api. Acceptable values are:
      • telemetry_api – will generate spans basing on data provided by the AWS Lambda Telemetry API. (before 0.3.0 this was the only way of tracing)
      • 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 (since 0.3.0) (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 (since 0.3.0) (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 (since 0.3.0) (optional): Defaults to 60000 (1 minute). Controls how often the tags will be refreshed.

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
  • Make sure to choose an ARN for the same region as your function.
  • Make sure to choose the layer corresponding to the architecture used by your function – x86_64 or arm64. If you are unsure about the architecture, it is displayed on the same page above the section where you’re selecting the layer.
  • If that function was already using coralogix-lambda-extension , we suggest removing it: Layers > Edit > Select the Lambda layer > Remove

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.

Note: 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

New! Coralogix AWS Lambda Telemetry Exporter version 0.2.0 now sends metrics. Check out our tutorial here.

Enrichment with tags

New! Coralogix AWS Lambda Telemetry Exporter version 0.3.0 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:

  • In AWS Console access the Lambda function that you would like to configure and go to: Configuration > Permissions
  • Click on the name of the execution role. This will bring to the IAM configuration of that role.
  • Click Add Permissions > Create inline policy
  • Switch to JSON view and paste the following policy JSON:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "lambda:ListTags",
            "Resource": "<paste lambda ARN here>"
        }
    ]
}
  • 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)
  • Click Review Policy
  • Give it a name. For example ListLambdaTags
  • Click Create Policy
  • Now you can 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.

Update Coralogix AWS Lambda Telemetry Exporter

Note! Coralogix AWS Lambda Telemetry Exporter version 0.2.0 introduces changes in log structure. You may need to adjust your queries, filters or parsing rules to work with the new log structure.

New! Coralogix AWS Lambda Telemetry Exporter version 0.3.0 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.

Coralogix AWS Lambda Telemetry Exporter version 0.2.0 now sends metrics. If you don’t wish to send metrics, you can use the CORALOGIX_LOG_METADATA_ENABLED variable documented above to disable them.

Updated the procedure for ARN-based installations

STEP 1. Look up the latest layer version

  • Look at the table 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.

  • Change the Telemetry Exporter layer version used by the function: Layers > Edit > Change to the looked up layer version > Save

Update the procedure for AWS Serverless Repository based installations

STEP 1. Redeploy the Telemetry Exporter Lambda layer from the AWS Serverless Repository into your AWS account.

  • Deploy the Coralogix-AWS-Lambda-Telemetry-Exporter in your AWS Serverless Application Repository. Make sure to deploy it in the same account and region as your Lambda function.
  • 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 2. Change the Telemetry Exporter layer version used by the function.

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

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