New Relic provides various tools for tracking your applications and infrastructure. It is great for tracking your application’s performance and troubleshooting issues. Two of those tools that we are going to discuss in this article are:
Go to New Relic dashboard and select APM from the navigation on top. Click on Add more, select NodeJS from languages and hit Reveal License Key to get your license key for the new app.
Next, go ahead and install the New Relic agent:
npm install --save newrelic
Now copy the newrelic.js file from
into your root directory.
cp node_modules/newrelic/newrelic.js .
This is your configuration file. Edit the file and add your
(this is how your application will show up on the dashboard) and
in the configuration file and you are all set. You should be seeing
the dashboard within a few minutes!
This is the New Relic configuration file. New Relic supports configurations from 4 different mechanisms in the following order of precedence (Server-side overrides environment variables which overrides agent configurations which overrides default configurations):
- Server-Side Configurations
- Environment Variables Configurations
- Agent Configurations (
- Agent Defaults Configurations (
config.default.jsfile. This can also be found under
This file can be found in
and contains all the configurations New Relic agent needs. You
modify this file.
This is the
newrelic.js file you copied to your
All your app level configurations should go in this file. This is
file looks like:
This is the file which can be distributed by your deployment script in case you want to specify different app_name and licenses for your staging/production environments (which is generally a good idea).
license_key is required. app_name is not required but it’s a good idea to set the app_name so that you can identify your application (especially when you have multiple) in the admin dashboard.
All the configurations supported in newrelic.js and config.default.js can be specified by environment variables by preceeding them with NEW_RELIC_. However, there are two configurations which can only be set via environment variables:
- NEW_RELIC_HOME: Points to the path of
- NEW_RELIC_NO_CONFIG_FILE: Tells the New Relic Agent to not read
These are the configurations which are done from the New Relic admin dashboard UI. A small subset of the configurations can be done from the dashboard and overrides any other values of these configurations anywhere else.
There are two ways to manage staging environments:
In order to do this, set the following environment variable:
You can do this permanently in your staging environment or you can set this variable temporarily if you want to disable New Relic from reporting temporarily.
You can create a separate app for your staging environment and
app_name in your
But of course, you will have to pay for a separate instance in this case
Head to Browser from the top navigation and hit Add more. From there, you have two ways to setup your browser application. If you are already using APM, the best way to do that will be via APM agent. Just select Enable via APM and then search and select the name of the APM app and hit Enable. That’s it!