How to Monitor Node.js Applications Using PM2 Web Dashboard

PM2 is a popular daemon process manager for Nodejs with a complete feature set for a production environment, that will help you manage and keep your application online 24/7.

A process manager is a “container” for applications that facilitates deployment, enables you to manage (start, restart, stop, etc..) the application at runtime, and provides for high availability.

In this article, we will show how to monitor Nodejs applications using PM2 from the command line and on the web. This guide assumes you already have PM2 installed on your Linux system and you are already running your Nodejs application using it. Otherwise, check out:

Note: All commands in this article are run as the root user, or use sudo command if you are logged in as an administrative user with permissions to invoke sudo.

Let’s get started…

Monitoring Nodejs Application Using PM2 Terminal

PM2 provides a terminal-based dashboard that helps you monitor the resource (memory and CPU) usage of your application. You can launch the dashboard by running the following command.

# pm2 monit

Once it running, use the left/right arrows to switchboards or sections. To view logs of an app, first select it (use up/down arrows) from the process list.

Monitor Nodejs Using PM2 on Terminal
Monitor Nodejs Using PM2 on Terminal

The terminal-based monitoring only works well for applications running on a single server. To monitor and diagnose cross-server applications, use the PM2 web-based dashboard.

Monitoring Nodejs Application Using PM2 Web-Based Dashboard

PM2 Plus (PM2 Web Based Dashboard) is an advanced and real-time monitoring and diagnostics tool. It provides features for both hardening your current PM2 and monitoring applications in production across servers. It features issues and exception tracking, deployment reporting, real-time logs, email and slack notification, custom metrics monitoring, and custom actions center.

The free plan allows you to connect up to 4 servers/applications. To start testing PM2 plus, go to app.pm2.io, then sign up as shown in the following screenshot.

PM2 Signup
PM2 Signup

After a successful login, create a bucket to group your Nodejs servers/applications. In this example, we have called our bucket TECMINT-APIs. Then click Create.

Create a Bucket Group for Nodejs
Create a Bucket Group for Nodejs

Next, link PM2 to PM2.io and copy the command provided as highlighted in the following interface.

Link PM2 to PM2.io
Link PM2 to PM2.io

Then run the above command on the Nodejs application server.

# pm2 link 7x5om9uy72q1k7t d6kxk8ode2cn6q9
Link PM2 to PM2.io on Nodejs Server
Link PM2 to PM2.io on Nodejs Server

Now on the PM2.io main interface, you should have one server connected, showing a list of all your Nodejs processes in expanded mode. For each server connected, the dashboard shows you server hardware components such as the amount of RAM and CPU type. It also shows the version of Nodejs and PM2 currently installed.

For each process, you will see the percentage of CPU and the amount of memory it is consuming, and much more. If you are using version control, it also shows the branch and last merge details.

Monitor Nodejs Applications from PM2.io Dashboard
Monitor Nodejs Applications from PM2.io Dashboard

To unlink a server from the app.pm2.io monitoring dashboard, run the following command on the server to unlink:

# pm2 unlink
Unlink Nodejs Server from PM2 Web Dashboard
Unlink Nodejs Server from PM2 Web Dashboard

After running the above command, you can delete the server from the app.pm2.io dashboard.

Monitoring Your Server Resources Using pm2-server-monit

pm2-server-monit is a PM2 module to automatically monitor key aspects of your server such as CPU average usage, free and used drive space, free and used memory space, all processes running, TTY/SSH opened, the total number of open files, as well as network speed (input and output).

To install it, run the following command:

# pm2 install pm2-server-monit
Install PM2 Server Monitoring Module
Install the PM2 Server Monitoring Module

If PM2 is linked to app.pm2.io, pm2-server-monit should automatically appear in the list of monitored processes. Now you can monitor your server resources from the web dashboard as shown in the following image.

Monitor Server Resources from PM2 Dashboard
Monitor Server Resources from PM2 Dashboard

To remove pm2-server-monit from your server, run the following command:

# pm2 uninstall pm2-server-monit

That’s it for now! You can share your thoughts about Nodejs application monitoring using PM2, with us via the feedback form below.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 thought on “How to Monitor Node.js Applications Using PM2 Web Dashboard”

  1. Please, when trying to use PM2 Web Dashboard I could not find a way to display real-time “console.log” messages sent from the running process. Is this resource available for beginners? Currently, I can have it in CLI mode by command pm2 myapp --attach.

    Thanks

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.