Node.js is all fun and games until…

As many of you know, I have been doing a ton of development. Some for my work at Cisco and some for fun. I like using PM2 to manage my node processes, logging, restarts, etc. As my integrations and bots have started getting more use I became fascinated/addicted with watching the logs for errors.

PM2 Log examle
Here is a snapshot of the logs that were stealing my attention

This was all great until last week, I realized it was really distracting me from my real job! I decided it was time to take these my hobby bots/apps to the next level.

I set out to find a solution that would alert me if a PM2 process reset/stopped, PM2 died, my server went offline as well as capture stack traces if/when a node process threw an exception.  Has an awesome option for this. If you are running node apps in production and are making money with them, this would be an excellent option. Since my apps are mostly running for free, I kept looking. I already have Zabbix set up to monitor the infrastructure for Douglas Automotive and was excited when I found a module was already written for Zabbix to monitor PM2!

Zabbix PM2 Graph
Zabbix PM2 graph displaying node process memory usage

This was fairly painless to configure. I will post some details below. Zabbix has me covered for the process monitoring, server load, resets, etc. But I still needed a solution for stack traces.

There are lots of options out there for capturing and analyzing logs in the cloud. Many of them come with a hefty monthly price tag. After trying a couple options. I decided to use, setting up an account and integrating into node was very simple.
Sample stack trace captured by

Here is an example of a stack trace from some tests I was doing.

With these two solutions in place, I hope to maintain my sanity and continue to write more code that other people find useful! I am always looking for better ways to do things. If you have a logging/monitoring solution that is better, let me know!

Zabbix Config Detail:

You can find the Zabbix PM2 module here. I am running Zabbix on an EC2 Amazon Linux AMI. The example startup files were written for Debian where Amazon Linux is more like CentOS/RHEL. After lots of trial and error I was able to make the following script work.


2 Replies to “Node.js is all fun and games until…”

  1. Hey! Thanks for featuring our software in the article. Glad it helped you achieve your goal. Sorry about the init script situation, which is indeed a bit awkward – with limited resources dedicated towards the utility, we are unable to test deployment on many platforms. What were your issues with the init script provided with the package? We welcome any input that helps develop pm2-zabbix.

    1. Hi Robert, it has been a while since I did the install. I will give the default script a shot this weekend and let you know what I was running into. Thanks again for creating it!

Leave a Reply

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