Agentless monitoring of Node.js (public preview)
With the Instana serverless collector, you can monitor your Node.js applications on servers without installing the Instana host agent. You can also monitor serverless environments for which Instana does not provide an npm package.
For more information about monitoring Node.js on AWS Lambda, AWS Fargate, or Google Cloud, see Restrictions.
Limitations
Currently, the Instana serverless collector package doesn't support the following features:
- AutoProfile
- Metrics collection
Before you begin
Check the installed Node.js version to ensure that it is compatibility with the Instana serverless collector. For more information, see Supported Node.js versions.
Setting up monitoring
To set up monitoring of Node.js applications, complete the following steps:
- Install the Instana serverless collector
- Activate the serverless collector
- Configure the serverless collector
After you install, activate, and configure the serverless collector, you can view traces in the Instana UI. For more information, see EUM correlation.
Installing the serverless collector
To install the serverless collector, run the following command:
npm install --save @instana/serverless-collector
Activating the serverless collector
After the serverless collector is installed, activate it within the application.
CommonJS
If the application uses CommonJS, activate the serverless collector by using one of the following methods:
NODE_OPTIONS
To activate the serverless collector by using this method, run the following command:
ENV NODE_OPTIONS="--require ./node_modules/@instana/serverless-collector/src/index.js"
Manual require
To activate the serverless collector by using this method, run the following command:
// Do not use require('@instana/serverless-collector')()!
require('@instana/serverless-collector');
// All other require statements must be done after the collector is initialized.
// Note the () after the require statement of the collector which initializes it.
// const express = require('express');
ECMAScript
If the application uses ECMAScript, activate the serverless collector as follows:
-
For Node.js 18.19.0 and later, run the following command:
ENV NODE_OPTIONS="--import ./node_modules/@instana/serverless-collector/esm-register.mjs"
-
For Node.js versions earlier to 18.19.0, run the following command:
ENV NODE_OPTIONS="--experimental-loader ./node_modules/@instana/serverless-collector/esm-loader.mjs"
You can also include the load flag when you run the Node.js startup command.
Configuring the serverless collector
After the serverless collector is installed and activated, you need to configure the serverless collector to submit the collected spans to the Instana backend.
To configure the serverless collector to send collected spans to the Instana backend, set the following environment variables:
INSTANA_ENDPOINT_URL
: Copy the serverless monitoring endpoint for your server’s region and set it as theINSTANA_ENDPOINT_URL
environment variable.INSTANA_AGENT_KEY
: From the navigation menu in the Instana UI, click More > Agents > Install Agents. Select a serverless platform, copy the provided key, and set it as theINSTANA_AGENT_KEY
environment variable.
End-user monitoring (EUM) correlation
After you install, activate, and configure the serverless collector successfully, tracing is enabled by default. To view the Instana backend correlation, complete the following step in the Instana UI:
- Create a website for your front end.
- After your Node.js application is configured, running, and receiving traffic, go to Applications > Services in the Instana UI and verify that traces are appearing on the dashboard.
- From the navigation menu in the Instana UI, click Websites & mobile apps and select your website.
- On your website dashboard, click HTTP Requests > Analyze HTTP Requests.
- View the backend trace by choosing a specific request.