Have you ever caught up in a no-clue situation with an application crash?
Did your client notify you about services being down?
Let’s explore the following Node.JS 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 and expert developers to ensure 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 is an enterprise-ready solution, that 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 the 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 the 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 the 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.
Sematext offers full-stack monitoring. Full-stack means you have complete visibility of your infrastructure and application availability & performance, metrics, logs, frontend user experience, health and performance of your APIs, SSL certificates, etc.
Sematext has over 100 integrations, including NodeJS. Here are some of them:
- Web servers – Nginx, Apache
- Database – MySQL, MariaDB, PostgreSQL, Redis
- Container – Kubernetes, Docker, Rancher
- Other languages – PHP, Scala, Python, Go, Java
- AWS – EC2, ELB, S3, Aurora
And a lot more…
NodeJS monitoring helps monitor latency, request rate, garbage collection, anomalies, workers, events, heartbeat, and more. You can visualize the data on a beautiful, readymade dashboard or create a custom one if needed.
Get notified when things are not okay through Slack, WebHooks, PageDuty, MS Teams, etc. Sematext offers an all-in-one comprehensive monitoring and logs analyzing solution. You can check the demo to experience the platform.
Better Uptime is a modern monitoring service that combines Uptime monitoring, incident management, and status pages into a single beautifully designed product.
The setup takes 3 minutes. After that, you get a call, email, or Slack alert, whenever your Node.js app doesn’t work correctly or stops working completely. The main features are:
- HTTP(s), Ping, API, SSL & TLD expiration, Cron jobs checks
- Unlimited phone call alerts
- Easy on-call scheduling
- Screenshots & error logs of incidents
- Slack, Teams, Heroku, AWS, and 100+ other integrations
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 web interface to monitor your applications.
You can use Appmetrics as a middleware to build your monitoring applications.
Raygun is a platform to manage and monitor application performance for multiple programming languages, including NodeJS. It helps you debug the issues in real time with crash logs, analyze the application code, and find 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.
Express Status Monitor
Express Status Monitoring is an open-source tool dedicated to monitoring ExpressJS. It is a known fact that ExpressJS is the most popular web framework used in NodeJS.
As you can see in the above snapshot, you can monitor response time, request frequency, status code, CPU/memory utilization, and average load.
Clinic.js is a library available to integrate with NodeJS applications to monitor and get 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.
AppSignal is a commercial product offering auto-instrumentation to Node.js HTTP call, Express, Next.js, and Postgress.
To get it started, you need to install a lightweight AppSignal agent on the server, which collects the necessary metrics. On a high level, it does the following.
- Monitor Performance – find and fix the code or infrastructure, slowing down the application availability and performance.
- Metrics – visualize what matters to you on the dashboard.
- Detect Anomaly – get notified when things are not as you expected.
- Monitor Server – don’t get another server monitoring software. You get all the standard resources metrics like CPU, Disk, Memory, Network, etc.
Prometheus + Grafana
The idea is to combine two powerful software – Prometheus and Grafana.
Prometheus has a client for Nodejs called prom-client, installed on the NodeJS server to collect the metrics. You can then install Grafana on the same server or remote to pull the metrics from Prometheus to visualize.
You may either create a Grafana dashboard from scratch based on the requirement or leverage the following two.
This requires you to know both the tools. If you need some help on Prometheus learning, then check out this Udemy course.
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 save time and effort and help you meet SLAs by delivering a faster resolution to the client.