Skip to content

PM2 Module to tail nginx error, access logs and send them to the specifed slack channel

License

Notifications You must be signed in to change notification settings

harshithkashyap/pm2-nginx-slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stream Nginx logs to Slack

Build Status

This module tails nginx error, access logs using node-tail and sends them to the specified slack channel.

Installation

pm2 install pm2-nginx-slack

Set slack webhook url

pm2 set pm2-nginx-slack:slack_access_log_url https://slack.url.com/ # Slack webhook to post access logs
pm2 set pm2-nginx-slack:slack_error_log_url https://slack.url.com/ # Slack webhook to post error logs

Defaults

{
    "slack_access_log_url": null,
    "slack_error_log_url": null,
    "access_log_path": "/var/log/nginx/access.log",
    "error_log_path": "/var/log/nginx/error.log",
    "tail_access_log": false,
    "tail_error_log": true,
    "status_codes": "400, 401, 403"
}
  • slack_access_log_url - Slack webhook URL to post access logs
  • slack_error_log_url - Slack webhook URL to post error logs
  • access_log_path - Path to your nginx access log(Default: /var/log/nginx/access.log)
  • error_log_path - Path to your nginx error log(Default: /var/log/nginx/error.log)
  • tail_access_log - Enable/Disable tailing access log(Default: false)
  • tail_error_log - Enable/Disable tailing error log(Default: true)
  • status_codes - HTTP status codes to filter access logs(Default: 400, 401, 403)

The above configurations can be modified with the following syntax and the changes are applied automatically by pm2.

pm2 set pm2-nginx-slack:tail_access_log true
pm2 set pm2-nginx-slack:access_log_path /path/to/your/nginx/access.log

Access logs

Access logs are disabled by default and can be enabled with the following command.

pm2 set pm2-nginx-slack:tail_access_log true

To filter nginx access logs, HTTP status codes 400, 401 & 403 are used by default. To enable filtering on custom HTTP status codes, use

pm2 set pm2-nginx-slack:status_codes "400, 404, 413" # Notice the comma-space seperated string

References

PM2-slack

License

License MIT

About

PM2 Module to tail nginx error, access logs and send them to the specifed slack channel

Resources

License

Stars

Watchers

Forks

Packages

No packages published