Node.js — Prerequisites
Prerequisites for monitoring Node.js with HEAL.
Prerequisites to complete before adding this component in the HEAL Control Center.
The prerequisites for Node JS components include:
You should configure Component Agent (CA) to collect data from an end point that you created in the target Node JS application. CA pushes this data to HEAL for further analysis. Following are the prerequisites for CA to collect Node JS behavior metrics data:
-
Install the following dependency from the root directory of the target application:
npm install prom-client@14.0.1Verify whether the above dependency is reflecting in the
package.jsonfile. This enables HEAL to collect metrics directly from the target application via an endpoint. -
Copy the HEAL instrumentation file
heal-oob-metrics.jsin the target application directory and import it as a dependency in the entry file of the target application.Following is a sample entry file which creates an endpoint/heal-nodejs-metricswhich needs to be accessible to CA:var express = require('express'); var cors = require('cors'); var bodyParser = require('body-parser'); var app = express(); require('dotenv').config() var port = process.env.port || 3001 app.use(bodyParser.json()) app.use(cors()) // HEAL Code: Create an endpoint to export nodejs metrics using HEAL instrumentation code. // insert before service is started. app.use('/heal-nodejs-metrics', require('./heal-oob-metrics')) app.listen(port, () => console.log(`API listening on port ${port}!`)); -
Once you register an endpoint, it starts collecting metrics from the Node JS application. CA needs to collect those metrics via this endpoint.CA needs to have access to the host address and port where this endpoint is running. Provide basic authentication details for CA to access this endpoint.
-
Running the target application. While starting the target Node JS application, set the following environment variable as the node argument:
HEAL_TARGET_APP="<Node JS target application name>" node <entry-file>Example:
HEAL_TARGET_APP="Pet-Clinic" node server.jsThis categorizes and states that the collected metrics are part of the mentioned application.
See also: Node.js (what HEAL monitors) · Setup & configuration guide