I was recently introduced to Slack by a friend of mine and found it to be quite awesome (especially if the organization that you are working in doesn’t block their site). It allows you to have all of the communication in the organization to be in one place. So I thought: “If that’s the place where all the communication goes, SiteScope should send it’s alerts there as well”. That’s how this SiteScope to Slack Alerts Integration idea was born.
The Integration is based on slack-webhook by gpedro. At the current version this Slack to SiteScope Alerts Integration is pretty basic: It uses standard SiteScope script alerts parameters to get the name of the monitor and its status, as well as the location of alerts file that is been created and drops the content as the Slack message attachment.
Enough theory let’s get to work!
- Go to https://your_team.slack.com/services/new
- Search for Incoming WebHook and click on Add
- Choose Channel to Post and press Add Incoming WebHooks Integration
- In the Setup Instructions section, you will find a WebHook URL.Copy the part after .…services/ (for example if your URL is https://hooks.slack.com/services/A1A1A1A1A/B2B2B2B2B/c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3 then copy aside the A1A1A1A1A/B2B2B2B2B/c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3 part)
- Download the SisToSlackAlert.zip file
- Here is what the zip file contains:
└───SisToSlackAlert │ SisToSlackAlert.bat │ ├───conf │ log4j.properties │ slack.properties │ ├───lib │ gson-2.3.1.jar │ log4j.jar │ PropUtils.jar │ SisToSlackAlert.jar │ └───logs SisToSlackAlert.bat.err.log SisToSlackAlert.bat.log
- You might have a warning about the zip file being dangerous, still proceed
SisToSlackAlert Zip file Browser Warning
- Extract its content under <SiteScope_Dir>\_custom folder (from now on it will be referenced as <SisToSlackAlert_Dir>)
- Copy the <SisToSlackAlert_Dir>\SisToSlackAlert.bat to <SiteScope_Dir>\scripts folder
SiteScope to Slack Alerts Integration Configuration
Update the <SiteScope_Dir>\scripta\SisToSlackAlert.bat file with your properties of your SiteScope deployment
|Location of SiteScope Root folder
|Location of SisToSlackAlert folder
Update the <SisToSlackAlert_Dir>\conf\slack.properties configuration file with your details:
|The id of your Webhook
|Slack Channel the alerts will be posted to. (if empty then the default channel that was used during Slack WebHook Integration will be used)
|Username that this integration will post as (if empty then the default username that was used during Slack WebHook Integration will be used)
|That’s icon that is used for messages from this SiteScope to Slack Alerts Integration. For more icons check http://www.emoji-cheat-sheet.com/
|I’ve made the bar on the left side of the message colour-dependant on the status. If you would like to tweak these colours update the following properties
|Attachment’s colour for Error messages
|Attachment’s colour for Warning messages
|Attachment’s colour for Good messages
If you you’ve extracted the SisToSlackAlert.zip to a location other than <SiteScope_Dir>\_custom update the <SisToSlackAlert_Dir>\conf\log4j.properties (the value you configure should be relative to the <SiteScope_Dir> folder).
SiteScope Alerts Configuration
Now, the only thing that needs to be done is:
- Create the alerts in SiteScope, the same regular way you are used to do it
- Add a new Script action. In the Script Action – select the SisToSlackAlert.bat script and as the first parameter pass the Status (Error/Warning/Normal)
By the way, if you already have an Alert set-up just add the required SisToSlackAlert actions
Results and Troubleshooting
So after you’ve finished your configuration you want to see some results!
The following SiteScope monitor
Should produce a Slack message similar to that one (the content of it depends on your script’s template)
If for some reason you don’t get the messages in Slack or the message seems different from what you expect try to look into the following logs:
- <SisToSlackAlert_Dir>\logs\SisToSlackAlert.bat.log – Logs parameters that the Java code was called with, Refreshed each time the Alert’s action is triggered.
- <SisToSlackAlert_Dir>\logs\SisToSlackAlert.bat.err.log – Logs Errors that occurred during the execution of the Java code was called with, Refreshed each time the Alert’s action is triggered
- <SisToSlackAlert_Dir>\logs\SisToSlackAlert.log – You will mostly find here logs related to the way that SiteScope data is converted to the Slack message and the message is designed. Logging severity can be changed in the <SisToSlackAlert_Dir>\conf\log4j.properties. That’s a daily log
I have a few thoughts about making this Slack to SiteScope Alerts Integration more robust and will be happy to hear your ideas about that. and any other thoughts you might have about the current version.