Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Monitor Node.js Applications Using PM2 Web Dashboard - DesignLinux

Oct 07 2020
designlinux 0 Comments

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:

  • How to Install PM2 to Run Node.js Apps on Production Server

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.

On this page

  • Monitor Nodejs Applications Using PM2 Terminal
  • Monitor Nodejs Applications Using PM2 Web Dashboard
  • Monitor Nodejs Server Resources Using pm2-server-monit

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.

Related

Tags: Nodejs Applications Monitoring, NodeJS Frameworks

How to Install Slack on CentOS 8

Prev Post

Pkill Command in Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 606
  • 1,055,378

DesignLinux.com © All rights reserved

Go to mobile version