Configuring the stand-alone Node.js data collector for IBM Cloud(formerly Bluemix®) applications

To collect information about Node.js applications on IBM® Cloud, you must configure the stand-alone Node.js data collector.

Before you begin

  1. Make sure that your Node.js application can run successfully locally. 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.
  2. Download the data collector package from IBM Passport Advantage® website. For detailed instructions, see Download instructions.
  3. Configure the data collector package with the make_configuration_packages.sh and configure_agent_images.sh scripts on the system where the Cloud APM server is installed. For detailed instructions, see Configuring the downloaded images.

Procedure

  1. Extract files from the data collector package. The nodejs_datacollector_8.1.4.0.6.tgz package is included in the extracted directory.
  2. 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
  3. 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.
  4. Copy the ibmapm folder that is extracted from the data collector package to the home directory of your application, for example, by running the following command:
    cp –r directory_to_the_ibmapm_folder  home_directory_of_your_Node.js_application
    Tip: The home directory of your Node.js application is determined by the command that you use to start the Node.js application and the directory that contains your main file. If you use the node app.js command to start your Node.js application and the app.js main file is in the /root/nodejs_app directory, /root/nodejs_app is the home directory of your application.
  5. 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.
    Example:
     "dependencies": {
        "ibmapm": "./ibmapm",
        "cors": "^2.5.2",
        "helmet": "^1.3.0",
        "loopback": "^2.22.0",
        "loopback-boot": "^2.6.5",
        "loopback-datasource-juggler": "^2.39.0",
        "serve-favicon": "^2.0.1",
        "strong-error-handler": "^1.0.1"
      }
  6. 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.
  7. From the directory that contains the manifest.yml file of your Node.js application, log in to IBM Cloud and then run the following command:
    cf push
    Tip: For a sample manifest.yml file, see Sample manifest.yml file.

Results

The data collector is configured and is connected to the Cloud APM server.

What to do next

You can verify that the monitoring data for your IBM Cloud application is displayed in the Cloud APM console. For instructions on how to start the Cloud APM console, see Starting the Cloud APM console. For information about using the Applications editor, see Managing applications.

Remember: To add your application to the Cloud APM console, choose Node.js Runtime in the application editor.