Get SQL Sentry Alerts on Slack
Published On: July 27, 2015
Categories: Alerting, SQL Sentry 4
Team collaboration tools seem to be all the rage these days, and rightfully so. With more and more people working from remote locations, tools like Slack and HipChat have become valuable productivity boosters.
Our Product Management team has grown recently, and we decided to give slack a try. Being the geeks that we are, one of the first things we did was set up several integrations with other SaaS based tools. It’s really great having so much important information funnel into a tool you’re using for team communication. If you haven’t tried it, I recommend checking it out.
That said, the next thing I wanted to do was to get SQL Sentry alerts going to a slack channel. I thought for a minute, and devised a plan to get this working using a little bit of geek ingenuity. I thought I would share this just in case someone else might be interested in doing the same.
You’ll need to make sure you have a few things handy to get this working:
- You need an account on slack.com, and a channel to send things to (you can create the channel on the fly though).
- You’ll need some form of supported email account. I used Office 365 mail, but gmail or Windows live mail (outlook.com) would work too.
- You’ll need an account for a web app called IFTTT (If This Then That, which is just the coolest thing since bacon wrapped shrimp).
- It would probably help to have SQL Sentry running as well. :-)
The workflow is actually pretty simple. On Slack, you enable the integration for IFTTT.
Then on IFTTT you create a recipe to post email from a specific sender to a Slack channel.
The only catch is that it does need to be a supported email system for IFTTT. It’s quite easy to search IFTTT to determine if the email system you want to use is supported. If not, there are plenty of options for free email accounts that are supported.
You could even just send it directly to IFTTT.
Once you have the IFTTT recipe enabled, all you need to do is configure the SQL Sentry alert(s) to use the “from address” in an email to the inbox you specified for the IFTTT recipe.
You can do this from the conditions pane docked on the right of the client by default. If you’ve closed it at some point, you can bring it back by selecting View -> Conditions on the main menu.
Use the “Add” button to add a new condition, and select “Send Email” for the action.
Once the condition has been added, you’ll be able to use several additional settings for the condition & action that control its behavior. For the “Send Email” action, one of those is the “From Address” of the email to be sent. This is also set to a default from the system-wide SMTP configuration, but you can override that here.
This is also where you select who the email is to be sent to.
I chose to use the “Top SQL: Completed” condition here for two reasons. First, it is very easy to trigger; and second, it contains several items of information to demonstrate. I actually don’t normally recommend enabling this condition in production environments, because it triggers so often. It is great to have for a development or test environment though, and there are some great use cases for it when applying a condition filter.
This one would tell me when someone is running queries from SSMS.
You can also customize the message using a custom message template, as outlined in the user guide.
For the greatest flexibility though, you can do this with Custom Conditions.
If everything is working correctly, you’ll get a nice message in the Slack channel that looks something like this:
Now if something interesting happens on one of the servers I’m monitoring, I’ll see it in Slack without having to switch to my email client.
IFTTT has tons of channels. You could perform this type of automation for something simple, like sending a text to your mobile phone, or something wild like turning the lights on when a server goes down using home automation.
Check out some of the other things you can do here: IFTTT Channels.
Jason has worked in technology for over 20 years. He joined SentryOne in 2006 having held positions in network administration, database administration, and software engineering. During his tenure at SentryOne, Jason has served as senior software developer and founded both Client Services and Product Management. His diverse background with relevant technologies made him the perfect choice to build out both of these functions. As SentryOne experienced explosive growth, Jason returned to lead SentryOne Client Services, where he ensures that SentryOne customers receive the best possible end to end experience in the ever-changing world of database performance and productivity.