Install APM Insight Node.js agent (versions 2.x and 3.x)

How to install the APM Insight Node.js agent (versions 2.x and 3.x)?

Warning
We highly recommend you download the latest version of the APM Insight Node.js agent. However, if you need to download agent versions v2.x or v3.x for some reason, kindly refer to the below given steps. 
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 you are 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. Follow any of the below:
  1. If you are using Common JS, follow the below instruction:
    Include the following code in the first line of your Node.js application start file before any other require statements.
      require('apminsight')()
    1. If you are using ES, follow the below instruction:
      Include the following code in the first line of your Node.js application start file before any other require statements.
        import apminsight from 'apminsight';
        apminsight.config()
    1. If you are using a typescript application, follow the below steps:
                    i. Create a file named apminsight.d.ts in the same directory as your application start file.
                    ii. Add the below line to the apminsight.d.ts file.
                         declare module "apminsight";
                    iii. Add the below lines to the first line of your application start file.
                          import * as 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 the 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 as environment variables using the following keys:
    1. License key - APMINSIGHT_LICENSE_KEY 
    2. Appname - APMINSIGHT_APP_NAME 
    3. Port - APMINSIGHT_APP_PORT
    4. proxyServerHost - APMINSIGHT_PROXYSERVER_HOST
    5. proxyServerPort - APMINSIGHT_PROXYSERVER_PORT
    6. proxyAuthUser - APMINSIGHT_PROXYAUTH_USER
    7. proxyAuthPassword - APMINSIGHT_PROXYAUTH_PASSWORD
    8. hostLicense - APMINSIGHT_HOSTLICENSE
      • Related Articles

      • How to identify and resolve conflicts between other APM products and the APM Insight .NET agent

        Problem statement: You are experiencing either of the below issues and suspect that another APM product is interfering with the Site24x7 .NET agent. 1. The .NET monitor is not created under APM > APM Insight > Applications, even after the .NET agent ...
      • Basic troubleshooting tips for the APM Insight Node.js agent

        If you are experiencing issues after installing the APM Insight Node.js agent, follow these troubleshooting tips. Verify agent installation and connectivity To verify the agent installation status, you can execute the following command from the root ...
      • Prerequisites for Node.js agent installation

        For a smooth Node.js agent installation, ensure that you've fulfilled the following prerequisites. The environment should have node version 16.20.2 or above installed. The application user should have full permission to access the agent directory. ...
      • Steps to troubleshoot if you see "NO Data" in the Node VM tab

        Problem statement: You are getting No Data under the garbage collection and event loop graphs such as GC Pause Time, GC Pause Frequency, and Event Loop Ticks Per Minute. Prerequisite: The Node.js agent version should be 3.0.0 or higher. Solution: The ...
      • APM Insight integration for Next.js in Kubernetes

        To integrate the Site24x7 APM Insight Next.js agent into your Kubernetes application using initContainers with the prebuilt agent image, follow the steps below: Prerequisites A Next.js application container image The Site24x7 APM Insight license key ...