Installing the Node.js data collector
Depending on your environment and whether you can access the internet, you can install the Node.js data collector by using different procedures.
Procedure
To install the data collector, complete one of the following procedures:
- If your environment can access the internet:
- To update the
package.json
, add"appmetrics": "^4.0.0"
as a dependency. - To update the main Node application file, add the
require('appmetrics');
to the beginning of the file.
- To update the
-
If your environment can't access the internet or if your company policy doesn't allow you to download packages from open source, complete the following steps:
-
Unpack the data collectors package according to your Node.js Runtime version:
tar xzf cp4mcm_DataCollectors_2.3.tar.gz cd cp4mcm_DataCollectors_2.3 tar zxf app_mgmt_runtime_dc_2020.2.2.tar.gz cd app_mgmt_runtime_dc_2020.2.2 tar zxf nodejs_datacollector_2020.2.0.tgz tar zxf <nodejs_package>
Where <nodejs_package> is the package file depending on your Node.js runtime version and operating system, for example,
ibmapm-greenfield-v8-lx64.tgz
. -
Copy or move the
ibmapm
folder that is created in step 1 to the root folder of your Node application. The root folder is the folder that contains the Node application file.mv ibmapm application_root_folder/ibmapm
- Add
require('./ibmapm');
to the first line of your application entry file.
-