Install APM Insight Node.js Agent


To install APM Insight Node.js agent, follow the below given instructions:

  1. In Applications Manager web client APM Insight tab > Help Card > copy the License Key present there.
  2. Download the APM Insight Node.js Agent file (apm_insight_agent_nodejs.zip) from the download page and extract it in the Node.js server.
  3. Open your Node.js application.
  4. Access the node packet manager (NPM).
  5. Use the following command to install an APM Insight Node.js agent from NPM.

    npm install <Node.js-Agent-unzipped-path>/agent_minified

    Example:

    npm install /users/joe/agent_minified

    If you want to deploy APM Insight agent to all the Node.js applications on the computer, use the global option via -g flag.

    npm install -g <Node.js-Agent-unzipped-path>/agent_minified

    Example:

    npm install -g /users/joe/agent_minified

    This will create an APM Insight directory under node_modules.

  6. Include the following code in the first line of your Node.js application source code, before any other require statement. Replace the variables with the values for your setup. 

    require('apminsight')({
      licenseKey : '[LICENSE-KEY]',
      appName : '[APPLICATION-NAME]',
      port : [APPLICATION-PORT],
      apmHost: '[APM-HOST-NAME]',
      apmPort: [APM-SSL-PORT]
    })

    Example:

    require('apminsight')({
      licenseKey : 'APMI_ee42094f83dd841d16b9c56796c22b63bef00ac6918f547280947d1f6c2be1ea',
      appName : 'Insight_NodeJS',
      port : 3000,
      apmHost: 'localhost',
      apmPort: 8443 
    })

  7. If you use proxy connections, enter this code instead:

    require('apminsight')({
      licenseKey : '[LICENSE-KEY]',
      appName : '[APPLICATION-NAME]',
      port : [APPLICATION-PORT],
      apmHost: '[APM-HOST-NAME]',
      apmPort: [APM-SSL-PORT]
      proxyServerHost : '[PROXY-SERVER]',
      proxyServerPort : [PROXY-PORT],
      proxyAuthUser : '[PROXY-USERNAME]',
      proxyAuthPassword : '[PROXY-PASSWORD]'
    })

  8. Save the file and restart your application.

Note:
1. The APM Insight Nodejs Agent is incompatible with other profiling tools, such as running the node process with the debugger mode (--inspect switch). 
2. If your application uses the cluster module, place the require statement in both the master and worker processes.