Skip to main content

AWS Lambda

Metrics

Deploy this integration to send your Amazon Lambda metrics to Logz.io.

This integration creates a Kinesis Data Firehose delivery stream that links to your Amazon Lambda metrics stream and then sends the metrics to your Logz.io account. It also creates a Lambda function that adds AWS namespaces to the metric stream, and a Lambda function that collects and ships the resources' tags.

Log in to your Logz.io account and navigate to the current instructions page inside the Logz.io app. Install the pre-built dashboard to enhance the observability of your metrics.

To view the metrics on the main dashboard, log in to your Logz.io Metrics account, and open the Logz.io Metrics tab.

Before you begin, you'll need:

  • An active account with Logz.io

Configure AWS to forward metrics to Logz.io

Create Stack in the relevant region

To deploy this project, click the button that matches the region you wish to deploy your Stack to:

RegionDeployment
us-east-1Deploy to AWS
us-east-2Deploy to AWS
us-west-1Deploy to AWS
us-west-2Deploy to AWS
eu-central-1Deploy to AWS
eu-north-1Deploy to AWS
eu-west-1Deploy to AWS
eu-west-2Deploy to AWS
eu-west-3Deploy to AWS
sa-east-1Deploy to AWS
ap-northeast-1Deploy to AWS
ap-northeast-2Deploy to AWS
ap-northeast-3Deploy to AWS
ap-south-1Deploy to AWS
ap-southeast-1Deploy to AWS
ap-southeast-2Deploy to AWS
ca-central-1Deploy to AWS

Specify stack details

Specify the stack details as per the table below, check the checkboxes and select Create stack.

ParameterDescriptionRequired/Default
logzioListenerThe Logz.io listener URL for your region. (For more details, see the regions page. For example - https://listener.logz.io:8053Required
logzioTokenYour Logz.io metrics shipping token.Required
awsNamespacesComma-separated list of the AWS namespaces you want to monitor. See this list of namespaces. If you want to automatically add all namespaces, use value all-namespaces.At least one of awsNamespaces or customNamespace is required
customNamespaceA custom namespace for CloudWatch metrics. This is used to specify a namespace unique to your setup, separate from the standard AWS namespaces.At least one of awsNamespaces or customNamespace is required
logzioDestinationYour Logz.io destination URL.Required
httpEndpointDestinationIntervalInSecondsThe length of time, in seconds, that Kinesis Data Firehose buffers incoming data before delivering it to the destination.60
httpEndpointDestinationSizeInMBsThe size of the buffer, in MBs, that Kinesis Data Firehose uses for incoming data before delivering it to the destination.5

Check Logz.io for your metrics

Give your data some time to get from your system to ours, then log in to your Logz.io Metrics account, and open the Logz.io Metrics tab.

Log in to your Logz.io account and navigate to the current instructions page inside the Logz.io app. Install the pre-built dashboard to enhance the observability of your metrics.

To view the metrics on the main dashboard, log in to your Logz.io Metrics account, and open the Logz.io Metrics tab.

Traces

Deploy this integration to auto-instrument your Node.js application running on AWS Lambda and send the traces to your Logz.io account. This is done by adding a dedicated layer for OpenTelemetry collector, a dedicated layer for Node.js auto-instrumentation and configuring environment variables of these layers. This integration will require no change to your application code.

note

This integration only works for the following AWS regions: us-east-1, us-east-2, us-west-1, us-west-2,ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1, ca-central-1.

Before you begin, you'll need:

note

Adding environmental variables using the AWS CLI commands below, will overwrite all existing variables for your Lambda function.

Important

This integration uses OpenTelemetry Collector Contrib, not the OpenTelemetry Collector Core.

Add the OpenTelemetry collector layer to your Lambda function

This layer contains the OpenTelemetry collector that will capture data from your application.

aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers arn:aws:lambda:<<YOUR-AWS-REGION>>:486140753397:layer:logzio-opentelemetry-collector-layer:<<LAYER_VERSION>>

Replace <<YOUR-LAMBDA_FUNCTION_NAME>> with the name of your Lambda function running the Node.js application.

Replace <<YOUR-AWS-REGION>> with the code of your AWS regions, e.g. us-east-1.

Replace <<LAYER_VERSION>> with the latest stable version for your region.

note

When adding the OpenTelemetry Collector to your Lambda function, it's important to include all necessary layers in a single command to avoid overriding existing configurations. This layer captures data from your application.

To add the OpenTelemetry Collector layer along with another layer, use the following format:

aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers arn:aws:lambda:<<YOUR-AWS-REGION>>:486140753397:layer:logzio-opentelemetry-collector-layer:<<LAYER_VERSION>> arn:aws:lambda:<<YOUR-AWS-REGION>>:486140753397:layer:another-layer:<<ANOTHER_LAYER_VERSION>>
Regionlogzio-opentelemetry-collector-layer
us-east-114
us-east-23
us-west-12
us-west-22
eu-north-12
eu-west-13
eu-west-23
eu-west-32
ca-central-13
ap-northeast-13
ap-northeast-23
ap-northeast-32
ap-south-12
ap-southeast-12
ap-southeast-22
sa-east-12

Create a configuration file for the OpenTelemetry collector

By default, the OpenTelemetry collector layer exports data to the Lambda console. To customize the collector configuration, you need to add a collector.yaml to your function and specifiy its location via the OPENTELEMETRY_COLLECTOR_CONFIG_FILE environment variable.

The collector.yaml file will have the following configuration:

receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"

exporters:
logzio/traces:
account_token: "<<TRACING-SHIPPING-TOKEN>>"
region: "<<LOGZIO_ACCOUNT_REGION_CODE>>"

service:
pipelines:
traces:
receivers: [otlp]
exporters: [logzio/traces]

Replace <<TRACING-SHIPPING-TOKEN>> with the token of the account you want to ship to.

Replace <LOGZIO_ACCOUNT_REGION_CODE> with the applicable region code.

The tail_sampling defines the decision to sample a trace after the completion of all the spans in a request. By default, this configuration collects all traces that have a span that was completed with an error, all traces that are slower than 1000 ms, and 10% of the rest of the traces.

You can add more policy configurations to the processor. For more on this, refer to OpenTelemetry Documentation.

The configurable parameters in the Logz.io default configuration are:

ParameterDescriptionDefault
threshold_msThreshold for the spand latency - all traces slower than the threshold value will be filtered in.1000
sampling_percentageSampling percentage for the probabilistic policy.10

Direct the OpenTelemetry collector to the configuration file

Add OPENTELEMETRY_COLLECTOR_CONFIG_FILE variable to direct the OpenTelemetry collector to the configuration file:

aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --environment Variables={OPENTELEMETRY_COLLECTOR_CONFIG_FILE=<<PATH_TO_YOUR_COLLECTOR.YAML>>}

Replace <<YOUR-LAMBDA_FUNCTION_NAME>> with the name of your Lambda function running the Node.js application.

Replace <<PATH_TO_YOUR_COLLECTOR.YAML>> with the actual path to your collector.yaml file.

Activate tracing for your Lambda function

aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --tracing-config Mode=Active

Replace <<YOUR-LAMBDA_FUNCTION_NAME>> with the name of your Lambda function running the Node.js application.

Add the OpenTelemetry Node.js wrapper layer to your Lambda function

The OpenTelemetry Node.js wrapper layer automatically instruments the Node.js application in your Lambda function.

aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --layers arn:aws:lambda:<<YOUR-AWS-REGION>>:486140753397:layer:logzio-opentelemetry-nodejs-wrapper:<<LAYER_VERSION>>

Replace <<YOUR-LAMBDA_FUNCTION_NAME>> with the name of your Lambda function running the Node.js application.

Replace <<YOUR-AWS-REGION>> with the code of your AWS regions, e.g. us-east-1.

Replace <<LAYER_VERSION>> with the latest stable version for your region.

Regionlogzio-opentelemetry-nodejs-wrapper
us-east-111
us-east-23
us-west-12
us-west-22
eu-north-12
eu-west-13
eu-west-23
eu-west-32
ca-central-13
ap-northeast-13
ap-northeast-23
ap-northeast-32
ap-south-12
ap-southeast-12
ap-southeast-22
sa-east-12

Add environment variable for the wrapper

Add the AWS_LAMBDA_EXEC_WRAPPER environment variable to point to the otel-handler executable:

aws lambda update-function-configuration --function-name <<YOUR-LAMBDA_FUNCTION_NAME>> --environment Variables={AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler}

Replace <<YOUR-LAMBDA_FUNCTION_NAME>> with the name of your Lambda function running the Node.js application.

note

For a much easier and more efficient way to collect and send metrics, consider using the Logz.io telemetry collector.