If you installed the Node.js application on Kubernetes, you can configure the Node.js data collector to collect information about the Node.js
application.
Before you begin
- Make sure that your Node.js application can run successfully. The stand-alone Node.js data collector can monitor Node.js V8.0.0 and future fix
packs, V10.0.0 and future fix packs, and V12.0.0 and future fix packs.
- Download the data collector package from
IBM®
Marketplace. For detailed
instructions, see Downloading your agents and data collectors.
Procedure
-
Extract files from the data collector package. The nodejs_datacollector_8.1.4.0.6.tgz package is included in the extracted
directory.
-
Extract the nodejs_datacollector_8.1.4.0.6.tgz file, for example, by
running the following command:
tar -zxf nodejs_datacollector_8.1.4.0.6.tgz
-
Extract the ibmapm.tgz file in the
nodejs_dc folder by running the following command:
tar -zxf nodejs_dc/ibmapm.tgz
You will get an ibmapm folder.
- In the package.json file of your Node.js application, add the
following line to the dependencies section:
"ibmapm": "./ibmapm"
Remember: Do not miss the comma at the end of each line in the file except the last one,
and keep the package.json file in good form.
-
Add the following line to the beginning of the main file of your Node.js application:
require('./ibmapm');
If you start your application by running the
node app.js command,
app.js is the main file of your
application.
- Rebuild your docker image.
Note: If you run your Node.js app on other Docker environments, for example, Docker Swarm or AWS
Docker services,you need to dockerize the steps.
What to do next
If you want to customize the monitoring, you can add environment
variables in your deployment yaml file. For details, see Customizing the stand-alone Node.js data collector for Kubernetes applications.