---
title: "Configuring NodeJS APM Agent"
canonical: "https://thoughtdata.refined.site/space/TUD/55186517/Configuring%20NodeJS%20APM%20Agent"
format: markdown
---
## Configuring NodeJS APM Agent

Configuring NodeJS APM agent requires some pre-requisite knowledge about your NodeJS application and is typically performed by application developers. Setting up NodeJS APM agent requires you to recompile your application by including NodeJS APM agent in the main file of your application. You will be required to make following changes on your application server

1. Install the NodeJS APM agent
2. Update your application main file by including a snippet code which calls the NodeJS APM agent during application startup
3. Recompile your NodeJS application

**Note:** if you are unsure of how to instrument your application with nodejs apm agent, contact ThoughtData's technical pre-sales team or technical support teams by sending an email to info@thoughtdata.com to assist with your configuration.

The below steps illustrates a sample example of how to instrument your NodeJS application with NodeJS APM agent on a linux server. 

Install npm package by running **"npm i elastic-apm-node --save"**

Update your nodejs application main file with following snippet of the code

  

      ***var apm = require('elastic-apm-node').start({***  
***
          ***  
***
          serviceName: process.env.APM_SERVICENAME,***  
***
          ***  
***
          serverUrl: process.env.APM_SERVERURL,***  
***
          ***  
***
          verifyServerCert: process.env.APM_VERIFY_CERT,***  
***
          ***  
***
          });***
    

**Note:** Place this code-snippet in the beginning of the main file before importing other modules.

Recompile your NodeJS application.

Copy the recompiled NodeJS application to the target server where you intend to run and monitor your NodeJS application 

Export the following to environment variable using following command

**export APM_SERVERURL="https://<dns-name-infrasense-machine"**  
**
        export APM_SERVICENAME="unique-application-name"**  
**
        export APM_VERIFY_CERT=false**

In the above

1. **APM_SERVERURL** parameter provide the proper full URL of your Infrasense sensor. E.g. : **https://192.168.1.241**. Alternatively, you can also use a DNS name if you have assigned a DNS name to your Infrasense sensor and your NodeJS application server can reach Infrasense over DNS name resolution.
2. **APM_SERVICENAME** parameter provide a proper service/application name by which you want ThoughtData's Enterprise360 to recognize your application. For E.g. : **production_news_app**
3. **APM_VERIFY_CERT** parameter leave it to **false **if you have not changed the self signed certificate on ThoughtData's APM server side. (Default value)

**Once the above settings are completed restart your NodeJS application**

This completes the configuration required on APM agent side for NodeJS, however you will need to start the APM server process on the sensor side to complete the APM monitoring configuration if you haven't already.

Refer to [Configuring Infrasense sensor for APM agents](https://thoughtdata.atlassian.net/wiki/spaces/TUD/pages/55481377/Configuring+APM+server+in+Infrasense+for+APM+RUM+Agents) topic for more information to complete the steps in setting up your APM Monitoring in Enterprise360