LogoLogo
StackState.comDownloadSupportExplore playground
StackState v5.1
StackState v5.1
  • Welcome to the StackState docs!
  • StackState self-hosted v5.1 docs
  • Getting Started
  • 🚀Setup
    • Install StackState
      • Requirements
      • Kubernetes / OpenShift
        • Kubernetes install
        • OpenShift install
        • Required Permissions
        • Non-high availability setup
        • Override default configuration
        • Configure storage
        • Configure Ingress
        • Install from custom image registry
        • Migrate from Linux install
      • Linux
        • Before you install
        • Download
        • Install StackState
        • Install with production configuration
        • Install with development configuration
        • Install with POC configuration
        • Set up a reverse proxy
        • Set up TLS without reverse proxy
      • Initial run guide
      • Troubleshooting
    • Upgrade StackState
      • Steps to upgrade
      • Version specific upgrade instructions
      • StackPack versions
      • StackState release notes
    • StackState Agent
      • About StackState Agent V3
      • Docker
      • Kubernetes / OpenShift
      • Linux
      • Windows
      • Advanced Agent configuration
      • Use an HTTP/HTTPS proxy
      • Agent V1 (legacy)
      • Migrate Agent V1 to Agent V2
        • Linux
        • Docker
    • StackState CLI
      • CLI: sts
      • CLI: stac (deprecated)
      • Comparison between CLIs
    • Data management
      • Backup and Restore
        • Kubernetes backup
        • Linux backup
        • Configuration backup
      • Data retention
      • Clear stored data
  • 👤Use
    • Concepts
      • The 4T data model
      • Components
      • Relations
      • Health state
      • Layers, Domains and Environments
      • Perspectives
      • Anomaly detection
      • StackState architecture
    • StackState UI
      • Explore mode
      • Filters
      • Views
        • About views
        • Configure the view health
        • Create and edit views
        • Visualization settings
      • Perspectives
        • Topology Perspective
        • Events Perspective
        • Traces Perspective
        • Metrics Perspective
      • Timeline and time travel
      • Analytics
      • Keyboard shortcuts
    • Checks and monitors
      • Checks
      • Add a health check
      • Anomaly health checks
      • Monitors
      • Manage monitors
    • Problem analysis
      • About problems
      • Problem lifecycle
      • Investigate a problem
      • Problem notifications
    • Metrics
      • Telemetry streams
      • Golden signals
      • Top metrics
      • Add a telemetry stream
      • Browse telemetry
      • Set telemetry stream priority
    • Events
      • About events
      • Event notifications
      • Manage event handlers
    • Glossary
  • 🧩StackPacks
    • About StackPacks
    • Add-ons
      • Autonomous Anomaly Detector
      • Health Forecast
    • Integrations
      • About integrations
      • 💠StackState Agent V2
      • 💠AWS
        • AWS
        • AWS ECS
        • AWS X-ray
        • StackState/Agent IAM role: EC2
        • StackState/Agent IAM role: EKS
        • Policies for AWS
        • AWS (legacy)
        • Migrate AWS (legacy) to AWS
      • 💠Dynatrace
      • 💠Kubernetes
      • 💠OpenShift
      • 💠OpenTelemetry
        • About instrumentations
        • AWS NodeJS Instrumentation
        • Manual Instrumentation
          • Prerequisites
          • Tracer and span mappings
          • Relations between components
          • Span health state
          • Merging components
          • Code examples
      • 💠ServiceNow
      • 💠Slack
      • 💠Splunk
        • Splunk
        • Splunk Events
        • Splunk Health
        • Splunk Metrics
        • Splunk Topology
      • 💠VMWare vSphere
      • Apache Tomcat
      • Azure
      • Cloudera
      • Custom Synchronization
      • DotNet APM
      • Elasticsearch
      • Humio
      • Java APM
      • JMX
      • Logz.io
      • MySQL
      • Nagios
      • OpenMetrics
      • PostgreSQL
      • Prometheus
      • SAP
      • SCOM
      • SolarWinds
      • Static Health
      • Static Topology
      • Traefik
      • WMI
      • Zabbix
    • Develop your own StackPacks
  • 🔧Configure
    • Topology
      • Component actions
      • Identifiers
      • Topology naming guide
      • Topology sources
      • Create a topology manually
      • Configure topology synchronizations
      • Enable email event notifications
      • Send topology data over HTTP
      • Set the topology filtering limit
      • Use a proxy for event handlers
      • Use tags
      • Tune topology synchronization
      • Debug topology synchronization
    • Telemetry
      • Add telemetry during topology synchronization
      • Data sources
        • Elasticsearch
        • Prometheus mirror
      • Send events over HTTP
      • Send metrics data over HTTP
      • Set the default telemetry interval
      • Debug telemetry synchronization
    • Traces
      • Set up traces
      • Advanced configuration for traces
    • Health
      • Health synchronization
      • Send health data over HTTP
        • Send health data
        • Repeat Snapshots JSON
        • Repeat States JSON
        • Transactional Increments JSON
      • Debug health synchronization
    • Anomaly Detection
      • Export anomaly feedback
      • Scale the AAD up and down
      • The AAD status UI
    • Security
      • Authentication
        • Authentication options
        • File based
        • LDAP
        • Open ID Connect (OIDC)
        • KeyCloak
        • Service tokens
      • RBAC
        • Role-based Access Control
        • Permissions
        • Roles
        • Scopes
        • Subjects
      • Secrets management
      • Self-signed certificates
      • Set up a security backend for Linux
      • Set up a security backend for Windows
    • Logging
      • Kubernetes logs
      • Linux logs
      • Enable logging for functions
  • 📖Develop
    • Developer guides
      • Agent checks
        • About Agent checks
        • Agent check API
        • Agent check state
        • How to develop Agent checks
        • Connect an Agent check to StackState
      • Custom functions and scripts
        • StackState functions
        • Check functions
        • Component actions
        • Event handler functions
        • ID extractor functions
        • Mapping functions
        • Monitor functions
        • Propagation functions
        • Template functions
        • View health state configuration functions
      • Custom Synchronization StackPack
        • About the Custom Synchronization StackPack
        • How to customize elements created by the Custom Synchronization StackPack
        • How to configure a custom synchronization
      • Integrate external services
      • Mirroring Telemetry
      • Monitors
        • Create monitors
        • Monitor STJ file format
      • StackPack development
        • How to create a StackPack
        • Packaging
        • How to get a template file
        • How to make a multi-instance StackPack
        • Prepare a multi-instance provisioning script
        • Upload a StackPack file
        • Prepare a shared template
        • Customize a StackPack
        • Prepare instance template files
        • Prepare a StackPack provisioning script
        • Resources in a StackPack
        • StackState Common Layer
      • Synchronizations and templated files
    • Reference
      • StackState OpenAPI docs
      • StackState Template JSON (STJ)
        • Using STJ
        • Template functions
      • StackState Markup Language (STML)
        • Using STML
        • STML Tags
      • StackState Query Language (STQL)
      • StackState Scripting Language (STSL)
        • Scripting in StackState
        • Script result: Async
        • Script result: Streaming
        • Time in scripts
        • Script APIs
          • Async - script API
          • Component - script API
          • HTTP - script API
          • Prediction - script API
          • StackPack - script API
          • Telemetry - script API
          • Time - script API
          • Topology - script API
          • UI - script API
          • View - script API
    • Tutorials
      • Create a simple StackPack
      • Push data to StackState from an external system
      • Send events to StackState from an external system
      • Set up a mirror to pull telemetry data from an external system
Powered by GitBook
LogoLogo

Legal notices

  • Privacy
  • Cookies
  • Responsible disclosure
  • SOC 2/SOC 3
On this page
  • Overview
  • Setup
  • Prerequisites
  • Supported Services
  • Installation
  • Upgrade
  • Disable OpenTelemetry Traces
  1. StackPacks
  2. Integrations
  3. OpenTelemetry

AWS NodeJS Instrumentation

StackState Self-hosted v5.1.x

PreviousAbout instrumentationsNextManual Instrumentation

Last updated 2 years ago

Overview

StackState provides an out-of-the-box OpenTelemetry solution for serverless AWS Lambda applications built with NodeJS. A modified OpenTelemetry Lambda Layer, based on the officially released , gives a plug-and-play user experience.

OpenTelemetry has the following benefits:

  • Lambda functions can include the OpenTelemetry Lambda Layer solution to collect trace data without the need to change any code.

  • The specific AWS Service that a Lambda communicates with is shown in StackState.

The StackState OpenTelemetry Lambda Layer can be used with AWS Lambda scripts running NodeJS 14.x (or later) and will transform the Topology in StackState as follows:

Setup

Prerequisites

To set up OpenTelemetry traces, you need to have:

  • AWS Lambda scripts running NodeJS 14.x (or later)

    • These will be the Lambda functions you wish to add OpenTelemetry support to.

    • They should be able to communicate with the StackState Agent.

Supported Services

Communication from AWS Lambda to:

  • AWS Lambda

  • AWS SQS

  • AWS SNS

  • AWS S3

  • AWS StepFunction

  • HTTP Endpoints

Installation

Follow the steps below to set up OpenTelemetry tracing for a NodeJS AWS Lambda script.

Note that the installation steps should be completed for every Lambda function that you wish to add OpenTelemetry tracing to.

After these steps have been completed, you should be ready to send traces to your StackState Agent.

Verify that the Lambda Layer exists

Verify that there is a Lambda Layer called stackstate-otel-nodejs.

If the Lambda Layer isn't present:

  • Lambda Layers are AWS REGION based. This means that the AWS StackPack CloudFormation template should also be deployed inside the same region as the targeted Lambda. If the CloudFormation template is currently deployed in another region other than where the targeted Lambda lives.

Underneath the Code tab, scroll down to the Layers section and click Add a layer on the right.

Select the Custom Layer radio box under Choose a layer. This will show two dropdowns at the very bottom of the page.

  • In the first dropdown, select the Lambda Layer stackstate-otel-nodejs

  • In the second dropdown, select the latest version number

Click Add to create the custom layer.

Set up tracing

A requirement to allow tracing to work is something called X-Ray headers. To set this up, follow ONE of the steps below:

    • X-Ray headers will be available, but X-Ray is still disabled; thus, no extra costs will be accumulated by using Pass-Through X-Ray.

    • Can only be set up using a CLI command.

OR

    • The more expensive option, as X-Ray will charge per Lambda execution.

Enable Active Pass-through

When the AWS CLI has been installed, run the following command in your terminal to set up your AWS Credentials:

aws configure

To verify if your Lambda function is running in Active Pass-Through, run the following AWS CLI commands. Unfortunately there is no way to verify this on the Console only through a CLI command:

aws lambda get-function-configuration \
--region <CHANGE TO THE REGION OF YOUR LAMBDA FUNCTION> \
--function-name <CHANGE TO THE NAME OF YOUR LAMBDA FUNCTION> \
--query 'TracingConfig.Mode'

You should be greeted with one of the following messages:

  • Active - the Lambda function is running in Active Pass-Through.

  • PassThrough - the Lambda function is running in Active Pass-Through.

  • Disabled or None - the function configuration needs to be updated. Run the command below to change the Lambda to Pass-Through and then verify the updated configuration by running the get-function-configuration command again:

    aws lambda update-function-configuration \
    --region <CHANGE TO THE REGION OF YOUR LAMBDA FUNCTION> \
    --function-name <CHANGE TO THE NAME OF YOUR LAMBDA FUNCTION> \
    --tracing-config "Mode=PassThrough"

Enable X-Ray Active Tracing

To enable Active X-Ray Tracing, go to the Configuration tab inside the Lambda and click Edit under Monitoring and operations tools.

Set the radio box Active tracing to true and click Save in the bottom right corner.

You can verify if Tracing is enabled by looking at the Active tracing block.

Add environment variables

For OpenTelemetry to start capturing traces, certain environment variables are required.

Create all of the following environment variables in the Configuration tab under Environment variables. Click the Edit button to add more.

  • StackState Agent OpenTelemetry Information

    • Trace Agent Port: 8126

    • OpenTelemetry StackState Agent Path: /open-telemetry

Required Environment variables

Key
Description
Value

AWS_LAMBDA_EXEC_WRAPPER

Allows the Lambda to root execution through OpenTelemetry. This allows OpenTelemetry to set up everything required to capture traces when the Lambda function executes.

/opt/otel-handler

OTEL_LOG_LEVEL

The amount of logging showed in the Lambda post-execution window.

info

OTEL_PROPAGATORS

The OpenTelemetry propagator context.

tracecontext

OTEL_TRACES_EXPORTER

The type of export used with OpenTelemetry.

otlp

OTEL_TRACES_SAMPLER

When execution data should be sampled.

always_on

OTEL_EXPORTER_OTLP_TRACES_ENDPOINT

Routing information from the Lambda to the StackState Agent. This needs to point to the open telemetry endpoint of your StackState Agent.

http://stackstate-agent-ip:8126/open-telemetry

Optional Environment variables

Key
Description
Default

HTTP_MASK_SENSITIVE_INFORMATION

If the HTTP URL traces path contains sensitive information, it can be masked by setting this environment variable to true. For example http://www.url.com/user/USERID/edit#test?query=123 will be captured as http://www.url.com effectively removing everything except the hostname

false

HTTP_REMOVE_HASH_DATA

Remove hash information from the captured HTTP URL traces. For example http://www.url.com#test?query=123 will be captured as http://www.url.com?query=123

false

HTTP_REMOVE_QUERY_DATA

Remove query information from the captured HTTP URL traces. For example http://www.url.com#test?query=123 will be captured as http://www.url.com#test

false

Upgrade

To upgrade the OpenTelemetry Lambda Layer to the latest version, including the Lambda function using the Lambda Layer, follow the steps described below.

Click on the layer stackstate-otel-nodejs to enter and view the details of the layer.

The Created box on the right should have a relative new time showing when it was created. Alternatively, go to any Lambda Function that's currently using the stackstate-otel-nodejs layer and compare the version it's using to the version displayed under the Version block for the layer.

Go to a Lambda function using the OpenTelemetry stackstate-otel-nodejs Lambda layer. Scroll down to the Layers section, and click the Edit button on the right.

Change the version for the stackstate-otel-nodejs layer to the latest version.

The Lambda will now use the latest OpenTelemetry Layer

Disable OpenTelemetry Traces

To disable OpenTelemetry tracing, go to the Lambda's configuration tab. Under the Environment variables section, remove the environment variable AWS_LAMBDA_EXEC_WRAPPER. This will disable the code routing through the OpenTelemetry Lambda Layer and restore your Lambda to the original running state.

v2.16 (or later)

StackState Agent should have . If traces aren't enabled on the Agent, OpenTelemetry won't generate any data.

The should be installed and configured in StackState. The AWS StackPack CloudFormation template will deploy the latest supported OpenTelemetry Lambda Layer (required for AWS OpenTelemetry functionality).

To test the configuration, execute the associated Lambda function. New Topology relations should be created and visible in the StackState UI within a minute or so. Relations will be created wherever your Lambda is communicating with any of the .

Go to the page listing all available Lambda Layer functions.

Change the region in the top-right corner to the region where the cloudformation template was deployed.

The AWS StackPack CloudFormation Template installed may not be the latest one containing the Lambda Layer. Follow the documentation to verify the installation of this StackPack.

Go to the page and navigate to the Lambda that you wish to add OpenTelemetry support to.

on your Lambda Function.

on the Lambda function.

To enable Active Pass-through you need the AWS CLI installed. Follow the steps to .

Make sure the latest is installed. The StackPack documentation contains the link to the latest OpenTelemetry Lambda Layer in the CloudFormation template.

After the latest StackPack CloudFormation template has been deployed, there should be a new version for the stackstate-otel-nodejs Lambda Layer. This can be confirmed on the page .

🧩
💠
StackState Agent
AWS StackPack
AWS Lambda Layers (console.aws.amazon.com)
AWS StackPack
AWS StackPack
Lambda functions (console.aws.amazon.com)
set up AWS CLI on your machine (docs.aws.amazon.com)
AWS StackPack
AWS Lambda Layers (console.aws.amazon.com)
Verify that the Lambda Layer exists
Set up tracing
Add the required environment variables
supported services
Enable Active Pass-through
Enable X-Ray Active Tracing
AWS Distro for OpenTelemetry Lambda (aws-otel.github.io)
List of Lambda Layers
Change Region
Edit Lambda Layer
Select Layer Version
Edit Active Tracing
Enable Active Tracing
Verify Active Tracing
Verify Active Tracing
List of Lambda Layers
List of Lambda Layers
List of Lambda Layers
List of Lambda Layers
Disable OpenTelemetry Tracing
traces enabled