Have you ever caught up in a no-clue situation with an application crash?
Let’s explore the following NodeJS monitoring tools that will help you monitor the application and server performance and other metrics.
PM2 has been the most famous tool used by Rookie as well as expert developers for ensuring that their applications are always live. PM2 is used for running live production workloads and monitoring them from CLI or web interface. You can install this as an NPM module.
PM2 provides the following features out of the box.
- Management of multiple NodeJS applications on a single server
- Application and error log management
- Web interface integration for monitoring application health and metrics
- Auto-clustering for NodeJS applications
- Hot reload of the application
- Support for start-up scripts
- Log streaming to a web interface
Getting started with PM2
To install PM2, ensure that you have NPM installed. To validate the installation and version of NPM, use the below command
This command should show you the version of NPM if it is installed.
Further, install PM2 using the below command:
npm install -g pm2
The global flag
-g will install and make the module available globally as a command. To start any application using PM2, Go to the folder containing NodeJS project and run the below command:
pm2 start <start-filename> --name myapp
The above command launches a NodeJs application using the file specified in the first argument. It also names the application with the name
myapp. When executing NodeJS application using
pm2, it ensures that the service does not go down, and if it does, it tries to auto-restart the application.
To enable live monitoring on web-interface, you need to register here. Once your keys are generated, you will be able to see the instructions on connecting PM2 on your server to the web interface.
Raygun is a platform to manage and monitor application performance for multiple programming languages, including NodeJS. It helps you to debug the issues in real-time with crash logs, analyzing the application code, and finding the right point of error from the code itself.
Some of the features are listed below.
- Provides live and precise error reports
- Supports full-stack error reporting
- Real-time user session monitoring
- Server performance monitoring and bottleneck detection realtime
Raygun is worth investing the time and money for mission-critical applications. It provides insights that can translate into great ROI.
Appmetrics is an open-source project managed and maintained by IBM. The project is focused on providing the barebones to collect excellent application metrics spread across various activities like data transaction, network speed, database query performance, CPU and memory utilization, garbage collection, and others.
Merging it with a plugin like appmetrics-dash could provide an excellent free online tool to monitor your applications.
You can use Appmetrics as a middleware to build your monitoring applications.
Express Status Monitor
As you can see in the above snapshot, you can monitor response time, request frequency, status code, CPU/memory utilization, and average load.
Prometheus is a community-powered monitoring and project performance insight tool. It has been exhaustively used by NodeJS developer communities to turn their performance metrics into useful insights. It doesn’t provide out of the box plug-n-play monitoring solution. You got to install and setup correctly to pull the data to visualize them.
If you are interested in learning, then I would suggest checking out this Udemy course.
Clinic.js is an open-source library available to integrate with NodeJS applications for monitoring and to get out critical performance parameters out of it. It is a combination of three main tools – Doctor, Bubbleprof, and Flame. Each of these tools is used for different metrics monitoring.
- Collect health and heuristics metrics
- Inject probes in the application automatically
- Provide a graphical interface to view the application performance and live metrics
- Generate recommendations for optimizing applications
- Plot bubble graphs describing internal application execution
- Helps you pinpoint the errors by showing function execution graphs
- Collects metrics using asynchronous hooks
- Provides latency information between function calls
- Dedicated CPU metrics monitoring
- Graphical UI for live monitoring CPU performance of the application
- Generates flame graphs helping to identify maximum values hit by metrics
- Provides insight into CPU consuming activities of your application
Commercial support is available if you need for your business.
Monitoring is often ignored yet very critical for application availability. With the cost of development being a crucial factor, tools that analyze code, monitor the performance, and provide an insight into errors, are sure of great worth. They not only save time and effort but also help you meet SLAs by delivering a faster resolution to the client.