Setting Up New Relic in Node.js Application: A Step-by-Step Guide with Examples

Setting Up New Relic in Node.js Application: A Step-by-Step Guide with Examples

Last updated on August 3rd, 2023


Setting Up New Relic in Node.js Application: Monitoring the performance and availability of your Node.js applications is crucial for maintaining a seamless user experience and identifying potential bottlenecks. New Relic is a powerful application performance monitoring (APM) tool that provides comprehensive insights into your application’s performance, allowing you to proactively identify and resolve issues. In this article, we will walk through the process of setting up New Relic in Node.js application, along with examples to help you get started.

Why New Relic?

New Relic is a powerful application performance monitoring (APM) tool that provides deep visibility into the performance and behavior of your Node.js applications. It allows you to track various metrics, such as response times, throughput, error rates, and database queries. With New Relic, you can proactively identify performance issues, optimize your application, and deliver exceptional user experiences.

Prerequisites for setting up new relic in node.js application

Before we dive into the setup process, make sure you have the following prerequisites in place:

  1. Node.js installed on your local machine or server.
  2. A New Relic account. If you don’t have one, sign up for a free trial at

Step 1: Sign Up for New Relic: Before we begin, you need to sign up for a New Relic account. Visit the New Relic website ( and create a new account if you don’t already have one. Once you’ve signed up, you’ll have access to your account dashboard and the necessary credentials to integrate New Relic into your Node.js application.

Step 2: Install the New Relic Package: In your Node.js project directory, open a terminal or command prompt and run the following command to install the New Relic package as a dependency:

npm install newrelic

Step 3: Configure New Relic: Create a new file called newrelic.js in the root directory of your Node.js application. This file will serve as the configuration file for New Relic. Add the following code to newrelic.js:

'use strict'

exports.config = {
  app_name: ['Your Application Name'],
  license_key: 'YOUR_NEW_RELIC_LICENSE_KEY',
  logging: {
    level: 'info'

Replace 'Your Application Name' with the name of your application and 'YOUR_NEW_RELIC_LICENSE_KEY' with the license key provided by New Relic.

Step 4: Modify the Application Entry Point: In the file where your application is initialized (typically index.js or app.js), add the following line of code at the top of the file:


Step 5: Restart your Application: Save the changes made to your files and restart your Node.js application. New Relic will now start monitoring your application’s performance.

Step 6: Viewing Application Performance Data: Once your application is running, go back to the New Relic dashboard and navigate to the APM section. You will find your application listed there. Click on your application to view detailed performance metrics such as response time, throughput, and error rate.

Example: Let’s consider a simple Express.js application to demonstrate setting up New Relic in node.js integration:

const express = require('express');
const newrelic = require('newrelic');
const app = express();

// Define your routes and middleware here

// Example route
app.get('/', (req, res) => {
  res.send('Hello, World!');

// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);

After following the above steps and restarting the application, you can navigate to the New Relic dashboard and observe real-time performance data for your application.


By setting up New Relic in Node.js application, you gain valuable insights into its performance, allowing you to identify and resolve issues before they impact your users. Monitoring and optimizing the performance of your application are essential steps in delivering a seamless user experience. With New Relic, you can proactively address performance bottlenecks and ensure your application runs smoothly.

Frequently Asked Questions (FAQs)

Q1: What is New Relic?

A1: New Relic is an application performance monitoring (APM) tool that helps developers monitor and optimize the performance of their applications in real-time.

Q2: Can I use New Relic with any Node.js application?

A2: Yes, New Relic can be integrated with any Node.js application, regardless of its size or complexity.

Q3: Are there any additional configuration options available for New Relic?

A3: Yes, New Relic provides extensive configuration options that allow you to fine-tune the monitoring settings according to your specific application requirements.

Q4: Can I monitor multiple applications using New Relic?

A4: Yes, New Relic allows you to monitor multiple applications from a single dashboard, making it convenient to manage and analyze their performance data.

Q5: Does New Relic provide alerts for critical performance issues?

A5: Yes, New Relic offers alerting functionality that allows you to set up notifications for specific performance thresholds, helping you address critical issues promptly.

Q6: Is New Relic only limited to Node.js applications?

A6: No, New Relic supports a wide range of programming languages and frameworks, including but not limited to Node.js, Java, Python, Ruby, and .NET.

Q7: Can New Relic help identify performance bottlenecks in my application?

A7: Absolutely! New Relic provides detailed insights into various aspects of your application’s performance, making it easier to pinpoint and resolve bottlenecks.

Q8: Is New Relic suitable for both development and production environments?

A8: Yes, New Relic can be utilized in both development and production environments, allowing you to monitor and optimize your application throughout its lifecycle.

Q9: Does New Relic have any cost associated with it?

A9: New Relic offers various pricing plans, including a free tier for basic monitoring needs. For more advanced features and higher usage levels, paid plans are available.

Q10: Can New Relic help improve the scalability of my Node.js application?

A10: Yes, New Relic’s performance monitoring capabilities can assist in identifying scalability issues and optimizing

Leave a Reply

Your email address will not be published. Required fields are marked *