slack: Send alerts and notifications to a Slack channel
The slack() destination driver sends messages to a Slack
channel using the Slack Web API. For the list of available optional parameters, see Slack destination options.
Prerequisites
-
AxoSyslog version 3.19 or later.
-
Install the
axosyslog-sclpackage on Debian/Ubuntu . On RHEL and compatible distributions , the SCL files are part of theaxosyslogbase package.Your configuration must also contain
@include "scl.conf", which the default configuration file already does. If the SCL files are missing, AxoSyslog fails to start with anunexpected LL_IDENTIFIERerror .Terminal window @include "scl.conf"The
slack()driver is a reusable configuration snippet (SCL). For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find its source in scl/slack/slack.conf on GitHub. -
This feature requires a separate module. Install the
axosyslog-mod-httppackage on Debian/Ubuntu , or theaxosyslog-httppackage on RHEL and compatible distributions . If the module isn’t installed, AxoSyslog fails to start with anunexpected LL_IDENTIFIERerror . -
Create a Slack app and a Webhook that AxoSyslog can use. For details, see the Slack documentation .
Declaration:
@include "scl.conf"
# ...
destination d_slack {
slack(
hook-url("https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
);
};The driver allows you to modify nearly every field of the HTTP request. For details, see the Slack API documentation .
You can use the proxy() option to configure the HTTP driver in all HTTP-based destinations to use a specific HTTP proxy that is independent from the proxy configured for the system.
By default, the throttle() option is set to 1, because Slack has a 1 message/second limit on Webhooks. It can allow more message in short bursts, so you can set it to 0, if you only expect messages in a short period of time. For details, see the Web API rate limiting in the Slack documentation
.
Example: Using the slack() driver
The following example sets the colors and the author of the message.
@include "scl.conf"
destination d_slack1 {
slack(
hook-url("https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
colors("#000000,#222222,#444444,#666666,#888888,#AAAAAA,#CCCCCC,#EEEEEE")
color-chooser(7)
author-name("Example BOT")
author-link("https://www.syslog-ng.com/products/open-source-log-management")
author-icon("https://raw.githubusercontent.com/MrAnno/vscode-syslog-ng/master/images/syslog-ng-icon.png")
);
};