Slack Webhook message posting for Good process monitor
good-slack
is a good reporter implementation to send hapi server events to
Slack using Incoming Webhooks.
Creates a new GoodSlack object with the following arguments:
config
- config objecturl
- a string with the Webhook URL[slack]
- an object of slack overridable parameters (See Incoming Webhooks)[format]
- MomentJS format string. Defaults to 'YYMMDD/HHmmss.SSS'.[host]
- a string with the server hostname. - Defaults to actual hostname.[basicLogEvent]
- a boolean to set the style oflog
events. When set to true,log
events will be sent as text instead of attachments. Defaults tofalse
.
Below is an example of using good-slack
and good-squeeze
together in a Hapi server to log all internal error messages to a slack channel.
const Hapi = require('hapi');
const Server = new Hapi.Server();
Server.connection();
Server.register([
{
register: require('good'),
options: {
reporters: {
slack: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{ error: '*' }]
}, {
module: 'good-slack',
args: [{ url: 'https://hook.slack.com/services/UNIQUE_SLACK_CHANNEL_URL' }]
}]
}
}
}
], (err) => {});
This version is compatible with good@7.x.x
which introduced major changes on reporter interface. For 6.x.x
support use v2.2.1.