Help APM Node.js Install Node.js agent

Install Node.js Agent

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

Installation steps for Node.js agent version 2.0:

  1. Open your Node.js application.
  2. Access the node packet manager (NPM).
  3. Use the command npm i apminsight --save to install an APM Insight Node.js agent from NPM. This will create an APM Insight directory under node_modules.
  4. Create a new file named apminsightnode.json and place it in the directory where you run the application. Add the below code snippet in the file. 
    {"licenseKey" : "<license-key>",
    "appName" : "<application-name>",
    "port" : <application-port> }

    If using Proxy:
    {"licenseKey" : "<license-key>",
    "appName" : "<application-name>",
    "port" : <application-port>,
    "proxyServerHost" : "<proxy-server>",
    "proxyServerPort" : <proxy-port>,
    "proxyAuthUser" : "<proxy-user-name>",
    "proxyAuthPassword" : "<proxy-password>"}
  5. Include the following code in the first line of your Node.js application start file before any other require statements.
    If using Common JS:
    require('apminsight')()

    If using ES:
    import apminsight from 'apminsight';
    apminsight.config()
  6. Copy and paste the license key in the apminsightnode.json file.
  7. Restart your application and make few transactions to view data in APM Insight client. 
If you are unable to add application port in apminsightnode.json file, you can add it in your application start file as mentioned below. However other parameters like license key and app name should be added only in apminsightnode.json file.
To add application port in application start file:
require(‘apminsight’)
(
{port:<application port>}
)

Set configuration values as environment variables:

You can set configuration values like license key, app name , and port as environment variables using the following keys:

  • License key - APMINSIGHT_LICENSE_KEY 
  • Appname - APMINSIGHT_APP_NAME 
  • Port - APMINSIGHT_APP_PORT

APM Insight Node.js version 1.x.x:

We highly recommend you to download the lastest version of APM Insight Node.js agent. But if you are looking to download agent verison 1.x.x, for some specific reasons, kindly refer the below given steps. 

Installation instructions - agent version 1.x.x

  1. Open your Node.js application.
  2. Access the node packet manager (NPM).
  3. Use the command npm i apminsight --save to install an APM Insight Node.js agent from NPM. This will create an APM Insight directory under node_modules.
  4. Include the following code in the first line of your Node.js application start file:
    require('apminsight')({
    licenseKey : '<device-key>',
    appName : '<application-name>',
    port : <application-port>
    })
    Example: require('apminsight')({
    licenseKey : 'sdafokjsoamdomkoamds',
    appName : 'myapp',
    port : 3000
    })
  5. If you use proxy connections,enter this code instead:
    require('apminsight')({
    licenseKey : '<device-key>',
    appName : '<application-name>',
    port : <application-port>  
    proxyServerHost : '<proxy-server>',
    proxyServerPort : <proxy-port>,
    proxyAuthUser : '<proxy-user-name>',
    proxyAuthPassword : '<proxy-password>' })

Note:You can find your license key by logging into Site24x7 then going to Admin>Developer> Device Key.

  1. Restart your application.
Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help APM Node.js Install Node.js agent