I know I can send alerts to slack, but I don't see the same options for actions under reports. Is it possible to send a scheduled report to a slack channel?
Excellent question. We are moving from HipChat to Slack within the next few weeks and I'd like to be able to send alerts directly to specific Slack groups.
These are two questions...
for reports -> slack, because these can be sent out as email, simply send the report to slack using something like this:
https://get.slack.help/hc/en-us/articles/206819278-Send-emails-to-Slack
for posting messages to a channel I use this perl script
c:\path-to-perl\perl.exe c:\path-to-scriptSWslack-notify.pl -p ${N=Alerting;M=Severity} -t "${N=Alerting;M=AlertMessage}" -H ${Caption} -D "${N=Alerting;M=AlertDetailsUrl}"
(note all of the arguments are parameters-- so I can reuse this action from different alerts, saving having to update lots of alerts. I simply add this action to an alert that we want posted to our slack channel.
use strict;use HTTP::Request::Common qw(POST);use LWP::UserAgent;use JSON;use Getopt::Std;#test#my $posturl='hooks.slack.com/.../CHANNEL API KEY GOES HERE';#netopsmy $posturl='hooks.slack.com/.../CHANNEL API KEY GOES HERE';# implement rate limiting -- no more than one messages per 5 secondsmy $ratefile ='c:\\temp\\slacksend.txt';my $ratelimit = 5;if (! -w $ratefile) { print "$ratefile does not exist!\n"; exit(1); }#exit ASAP if the ratefile has been touched in the last $ratelimit seconds exit(0) if ((time - (stat($ratefile))[9]) < $ratelimit);#touch the ratelimit fileutime(undef, undef,$ratefile);#Parse optionsmy %opts;getopts('p:t:H:D:',\%opts);#build the payloadmy $payload = { channel => 'testchan' , username => 'Solarwinds', icon_emoji => ':construction:', text => "$opts{t}", };if (($opts{p} eq 'Serious') || ($opts{p} eq 'Critical')) { $payload->{text} .= ' '; $payload->{attachments} = [ { fallback => "Problem: $opts{H} $opts{S} $opts{D} }", color => 'danger', fields => [ { title => 'Host', value => $opts{H}, short => 'false', }, { title => 'Detail', value => $opts{D}, short => 'false', } ], # fields }, # attachment 1 ];} else { # something unknown, just display it flat. $payload->{color} = 'danger'; $payload->{text} = "$opts{t} $opts{H} $opts{S} $opts{D}";}my $ua = LWP::UserAgent->new;$ua->timeout(15);my $req = POST("${posturl}", ['payload' => encode_json($payload)]);my $resp = $ua->request($req);