{"id":17493328,"url":"https://github.com/mattpker/pm2-slack","last_synced_at":"2025-04-07T15:10:05.632Z","repository":{"id":47392738,"uuid":"44634076","full_name":"mattpker/pm2-slack","owner":"mattpker","description":"A PM2 module to emit events to Slack","archived":false,"fork":false,"pushed_at":"2019-07-29T20:11:51.000Z","size":33,"stargazers_count":144,"open_issues_count":5,"forks_count":73,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-24T23:01:02.193Z","etag":null,"topics":["node","node-module","nodejs","nodejs-modules","pm2","slack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattpker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-20T20:48:54.000Z","updated_at":"2024-04-13T13:16:42.000Z","dependencies_parsed_at":"2022-08-17T14:55:07.919Z","dependency_job_id":null,"html_url":"https://github.com/mattpker/pm2-slack","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattpker%2Fpm2-slack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattpker%2Fpm2-slack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattpker%2Fpm2-slack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattpker%2Fpm2-slack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattpker","download_url":"https://codeload.github.com/mattpker/pm2-slack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675607,"owners_count":20977378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node","node-module","nodejs","nodejs-modules","pm2","slack"],"created_at":"2024-10-19T12:06:33.667Z","updated_at":"2025-04-07T15:10:05.609Z","avatar_url":"https://github.com/mattpker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pm2-slack\n\nThis is a PM2 Module for sending events \u0026 logs from your PM2 processes to Slack.\n\n## Install\n\nTo install and setup pm2-slack, run the following commands:\n\n```\npm2 install pm2-slack\npm2 set pm2-slack:slack_url https://slack_url\n```\n\nTo get the Slack URL, you need to setup an Incoming Webhook. More details on how to set this up can be found here: https://api.slack.com/incoming-webhooks\n\n## Events subscription configuration\n\nThe following events can be subscribed to:\n\n- `log` - All standard out logs from your processes. Default: false\n- `error` - All error logs from your processes. Default: true\n- `kill` - Event fired when PM2 is killed. Default: true\n- `exception` - Any exceptions from your processes. Default: true\n- `restart` - Event fired when a process is restarted. Default: false\n- `reload` - Event fired when a cluster is reloaded. Default: false\n- `delete` - Event fired when a process is removed from PM2. Default: false\n- `stop` - Event fired when a process is stopped. Default: false\n- `restart overlimit` - Event fired when a process is reaches the max amount of times it can restart. Default: true\n- `exit` - Event fired when a process is exited. Default: false\n- `start` -  Event fired when a process is started. Default: false\n- `online` - Event fired when a process is online. Default: false\n\nYou can simply turn these on and off by setting them to true or false using the PM2 set command.\n\n```\npm2 set pm2-slack:log true\npm2 set pm2-slack:error false\n```\n\n## Options\n\nThe following options are available:\n\n- `slack_url` (string) - Slack Incomming Webhook URL.\n- `servername` / `username` (string) - Set the custom username for Slack messages (visible in message headers). Default: server hostname\n- `buffer` (bool) - Enable/Disable buffering of messages. Messages that occur in short time will be concatenated together and posted as a single slack message. Default: true\n- `buffer_seconds` (int) - If buffering is enables, all messages are stored for this interval. If no new messages comes in this interval, buffered message(s) are sended to Slack. If new message comes in this interval, the \"timer\" will be reseted and buffer starts waiting for the new interval for a new next message. *Note: Puspose is reduction of push notifications on Slack clients.* Default: 2\n- `buffer_max_seconds` (int) - If time exceed this time, the buffered messages are always sent to Slack, even if new messages are still comming in interval (property `buffer_seconds`). Default: 20\n- `queue_max` (int) - Maximum number of messages, that can be send in one Slack message (in one bufferring round). When the queue exceeds this maximum, next messages are suppresesed and replaced with message \"*Next XX messages have been suppressed.*\". Default: 100\n\nSet these options in the same way as subscribing to events.\n\n\n###### Example\n\nThe following configuration options will enable message buffering, and set the buffer duration to 5 seconds. All messages that occur within maximum 5 seconds delay between two neighboring messages will be concatenated into a single slack message.\n\n```\npm2 set pm2-slack:slack_url https://hooks.slack.com/services/123456789/123456789/aaaaaaa\npm2 set pm2-slack:buffer_seconds 5\n```\n\nNote: In this example, the maximum total delay for messages is still 20 seconds (default value for `buffer_max_seconds`). After this time, the buffer will be flushed\neverytime and all messages will be sent.\n\n### Process based custom options\n\nBy default, all options are defined for all processes globally.\nBut you can separately define custom options to each PM2 process.\nUse format `pm2-slack:optionName-processName` to process based custom options.\n\nIf no custom options is defined, the global `pm2-slack:propertyName` will be used.\n\nNote: By this way, all custom options can be used for specific process, but events subsciptions configuration is always global only.\n\n###### Example\n\nWe have many processes, includes process `foo` and process `bar`.\nFor this two processes will have to define separate Slack URL channel and separate server name.\nSame buffer options will be used for all processed. \n\n```\n# Define global options for all processes.\npm2 set pm2-slack:buffer_seconds 5\n\n# Define global options for all processes.\n#   (for process `foo` and `bar` the values will be overridden below).\npm2 set pm2-slack:slack_url https://hooks.slack.com/services/123456789/123456789/aaaaaaa\npm2 set pm2-slack:servername Orion\n\n# Define custom Slack Incomming Webhoook for `foo` process.\npm2 set pm2-slack:slack_url-foo https://hooks.slack.com/services/123456789/123456789/bbbbbbb\npm2 set pm2-slack:servername-foo Foo-server\n# Note: The `pm2-slack:buffer_seconds`=5 will be used from global options for this process. \n\n# Define custom Slack Incomming Webhoook for `bar` process\npm2 set pm2-slack:slack_url-bar https://hooks.slack.com/services/123456789/123456789/ccccccc\npm2 set pm2-slack:servername-foo Bar-server\n# Note: The `pm2-slack:buffer_seconds`=5 will be used from global options for this process. \n```\n  \n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.\n\n## Release History\n- 1.1.0 Custom options can be defined to each PM2 process.\n        Displaying process ID of cluster mode processes (thanks @abawchen). \n- 1.0.0 Message bufferring refactored. Message grouping refactored.\n        Added datetime parsing from log messages.\n- 0.3.4 Added an option to override the Slack username\n- 0.3.3 Added documentation for the reload event\n- 0.3.2 Fixed Half width of error and log messages (thanks @ma-zal)\n- 0.3.1 Fixed Double escaping of error and log messages (thanks @ma-zal)\n- 0.3.0 Switched to a default buffer system that groups alike messages by timestamp in the same message to Slack (thanks @kjhangiani)\n- 0.2.0 Implemented a rate limiting system and updated all the dependencies\n- 0.1.1 Commenting \u0026 Clean up\n- 0.1.0 Initial Release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattpker%2Fpm2-slack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattpker%2Fpm2-slack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattpker%2Fpm2-slack/lists"}