Install Node.js with IBM Cloud

  1. Install the latest LTS (Long Term Support) version of Node.js.

  2. To install from npm, run this command from the app root directory:

    npm install @contrast/agent

    Alternatively, if you use yarn, run this command to install the agent:

    yarn add @contrast/agent
  3. Configure the Node.js using a YAML configuration file to set the authentication keys and any application-specific configuration.

    You can use this sample contrast_security.yaml file, but replace <URL>, <UserName>, <APIKey> and <ServiceKey> with your values, and set <ServerName> to the name of the IBM cloud server to which this application will report. (This way you will be able to identify the server when you view it in Contrast.)

       url: <URL>
       user_name: <UserName>
       api_key: <APIKey>
       service_key: <ServiceKey>
       name: <ServerName>
  4. Create a folder named contrast in your application’s root directory. and move the node-contrast-.tgz and the contrast_security.yaml files into the contrast folder.

  5. Add this command to the "scripts": section of your application's package.json file:

    "ibmcloud-with-contrast": "npm install @contrast/agent && node -r @contrast/agent index.js -c /home/vcap/app/contrast/contrast_security.yaml",
  6. Since IBM Cloud runs the start script by default, you must change the start command to point to the ibmcloud-with-contrast line given in the previous step. Run the agent using:

    "start":"npm run ibmcloud-with-contrast"

    Now the scripts section of the package.json should look like the following:

    "scripts": {
    "bluemix-with-contrast": "npm install @contrast/agent && node -r @contrast/agent index.js -c /home/vcap/app/contrast/contrast_security.yaml",
    "start":"npm run bluemix-with-contrast”
  7. Push the application to IBM Cloud using:

    cf push <application-name> -t 180
  8. Run the agent with:

    npm start contrast
  9. Exercise your application by performing either manual or automated testing to ensure your application is functioning correctly with the agent installed.

  10. Verify that your server is registered in Contrast and reports an instance of your application.