https://github.com/imskully/pm2-papertrail-logger
A simple and efficient PM2 module that forwards logs to Papertrail.
https://github.com/imskully/pm2-papertrail-logger
hacktoberfest papertrail pm2 pm2-module
Last synced: about 1 year ago
JSON representation
A simple and efficient PM2 module that forwards logs to Papertrail.
- Host: GitHub
- URL: https://github.com/imskully/pm2-papertrail-logger
- Owner: ImSkully
- License: gpl-3.0
- Created: 2023-08-09T22:11:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-02T00:31:30.000Z (almost 2 years ago)
- Last Synced: 2025-03-26T05:51:12.956Z (about 1 year ago)
- Topics: hacktoberfest, papertrail, pm2, pm2-module
- Language: JavaScript
- Homepage:
- Size: 236 KB
- Stars: 5
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README



A simple and efficient [PM2](https://pm2.keymetrics.io) module that forwards logs for all your PM2 processes to [Papertrail](https://papertrailapp.com):
* ⚡️ Fast and lightweight, unpacked size of 54kb!
* 🔒 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
# Prerequisites
### PM2
This module requires that you have [PM2](https://pm2.keymetrics.io) installed and running on your system. If you do not have PM2 installed, you can install it via NPM:
```bash
npm install pm2 -g
```
### Papertrail
In order to use this module and forward all your pm2 process logs, you must have a [Papertrail](https://papertrailapp.com) 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](https://www.papertrail.com/help/heroku/).
Within your Papertrail account, you will need a [Log Destination](https://papertrailapp.com/account/destinations) that accepts connections via TCP/UDP Ports. Once this is setup, take note of your destination host *(\*.papertrailapp.com)* and port number.
# Installation & Setup
1. Install the module via `pm2`:
```bash
pm2 install pm2-papertrail-logger
```
> [!IMPORTANT]
> Use `pm2 install`, not `npm install`!
2. Configure the Papertrail log destination by providing your host and port number:
```bash
pm2 set pm2-papertrail-logger:host
pm2 set pm2-papertrail-logger:port
```
3. The module should restart and begin logging to Papertrail!
# Usage
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`](https://my.papertrailapp.com/events) tab within your Papertrail account.
### Change Hostname
By default, the host name sent to Papertrail will be the OS hostname, you can change this by setting the hostname configuration variable:
```bash
pm2 set pm2-papertrail-logger:hostname
```
### Process as Systems
If you would like to have each PM2 process be created as its own system group within Papertrail, you can set the `process-as-systems` configuration to `true`:
```bash
pm2 set pm2-papertrail-logger:process-as-systems true
```
### Blacklist
To prevent certain PM2 processes from being logged to Papertrail, you can set a blacklist of process names in the `blacklist` configuration variable which is a comma-separated list of process names:
```bash
pm2 set pm2-papertrail-logger:blacklist "process1,process2"
```
### PM2 Metrics
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. |
# Uninstalling
To uninstall the module, simply run:
```bash
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:
```bash
pm2 unset pm2-papertrail-logger:host
pm2 unset pm2-papertrail-logger:port
pm2 unset pm2-papertrail-logger:hostname
pm2 unset pm2-papertrail-logger:process-as-systems
pm2 unset pm2-papertrail-logger:blacklist
```