Get SQL Sentry Alerts on Slack - SentryOne Team Blog

Get SQL Sentry Alerts on Slack

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.

Preparation

You’ll need to make sure you have a few things handy to get this working:

  1. You need an account on slack.com, and a channel to send things to (you can create the channel on the fly though).
  2. 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.
  3. 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).
  4. It would probably help to have SQL Sentry running as well. :-)

The Approach

The workflow is actually pretty simple. On Slack, you enable the integration for IFTTT.

image

Then on IFTTT you create a recipe to post email from a specific sender to a Slack channel.

image

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.

image

The Setup

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.

image

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.

image

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.

image

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.

The Results

If everything is working correctly, you’ll get a nice message in the Slack channel that looks something like this:

image

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.

More Fun

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.

Comments ( 4 )

      • Dan Thompson says:

        This could also be done with Flow in Office 365 – in fact a lot of actions can be performed in there…
        When an email comes in you could post in a Slack channel, Create an Incident in PagerDuty or Jira or Create a new task/card in Trello, Wunderlist, Yammer for example… very handy!

      • Jason Hall says:

        Thanks Dan,

        Yes, I believe that when I wrote this MS Flow was in its infancy. Today it is definitely a great option for this type of automation, and even better in some cases due to support for things like Common Data Service.

      • Hiren Patel says:

        Hi Jason,
        Is there any plan or utilizing direct incoming webhooks instead of IFTTT?

        Thank you,
        Hiren Patel

      • Jason Hall says:

        Hello Hiren,

        Yes, we have plans along these lines. I can't reveal specifics just yet, but I think you will be pleased. If you would like to discuss this topic more, please feel free to email me at jhall at SentryOne dot com.

      Leave A Comment

      Your email address will not be published.