A simple and efficient PM2 module that forwards logs for all your PM2 processes to Papertrail:
- ⚡️ Fast and lightweight, unpacked size of 45kb!
- 🔒 Secure with all logs sent over TLS
- 🔧 Easy to install and configure, deployed with 3 easy commands within a matter of seconds!
- 📝 Adjustable hostname for your pm2 source
- 🚀 Supports all PM2 process modes, including cluster, fork, and standalone.
- 📦 Memory management and automatic cleanup for closed processes
This module requires that you have PM2 installed and running on your system. If you do not have PM2 installed, you can install it via NPM:
npm install pm2 -g
In order to use this module and forward all your pm2 process logs, you must have a Papertrail Standalone account, this will not work for Papertrail instances that are attached as an addon to a Heroku application. For information on setting up a Papertrail Standalone account, click here.
Within your Papertrail account, you will need a Log Destination that accepts connections via TCP/UDP Ports. Once this is setup, take note of your destination host (*.papertrailapp.com) and port number.
-
Install the module via
pm2
:pm2 install pm2-papertrail-logger
[!IMPORTANT]
Usepm2 install
, notnpm install
! -
Configure the Papertrail log destination by providing your host and port number:
pm2 set pm2-papertrail-logger:host <host> pm2 set pm2-papertrail-logger:port <port>
-
The module should restart and begin logging to Papertrail!
Once the module is installed and configured, it will automatically begin logging all your PM2 processes to Papertrail. You can view the logs by clicking on the Events
tab within your Papertrail account.
By default, the host name sent to Papertrail will be the OS hostname, you can change this by setting the hostname configuration variable:
pm2 set pm2-papertrail-logger:hostname <hostname>
This module also provides metrics that can be viewed within the PM2 dashboard.
Metric | Description |
---|---|
Attached Processes |
The number of processes that are currently transporting logs to Papertrail. |
To uninstall the module, simply run:
pm2 uninstall pm2-papertrail-logger
This will remove the module from your PM2 configuration and stop it from running, you may also want to remove the configuration variables that were set:
pm2 unset pm2-papertrail-logger:host
pm2 unset pm2-papertrail-logger:port
pm2 unset pm2-papertrail-logger:hostname