Site Down Alerts using Azure App Insights and Zapier
3 min read

Site Down Alerts using Azure App Insights and Zapier

It's happened again. Even though I do get emailed whenever KTOMG goes down, I don't pay attention to my email 24/7 and the site can be down for a bit until I realize it. In this case, I was cooking and wasn't at my computer or on my phone. The Twitter notification by a friendly user actually got me to check!

I know this is one of the headaches I willingly signed up for by moving to my own VM--and even though I get emailed when the site's down I hate not knowing that immediately.

App Insights

The first thing you should do is get an Azure App Insights account. It's free. And you can even use it to monitor your own VMs! This is how I can still get this for KTOMG:

Server Metrics

It's awesome.

The other thing it can do is handle availability (ping) tests. It's very easy to set up and then you can set an alert for it. I've done this already, where I've set it to email me whenever KTOMG is down at more than 3 locations over 3 minutes--in other words, my site has blown up.

Using a Webhook with Zapier

I also use Zapier, which is just a (fancier?) IFTTT clone. When I had deployed via Azure, I had set up a Zap to notify me whenever my Azure sites were deployed. Since I'm on my own now, I disabled that but now I'll show you how to use it to notify you via SMS and webhooks.

  1. Sign up for an account
  2. Create a new Zap
  3. Select "Webhook by Zapier" as the trigger
  4. Go through the steps until you get a new webhook URL
Webhook url

Now you've got a webhook URL which is just an HTTP endpoint you can POST to.

In Azure App Insights, you'll want to paste this URL into your alert "Webhook" setting:

Webhook settings

Zapier will be asking you to test your hook. It's a bit hard to trigger an Azure alert, but all you really need to do is POST a JSON payload at the endpoint, so going off this Azure guide, use something like curl or Postman to POST to the endpoint:

Testing the hook

Now that the hook is tested, Zapier has filled in a bunch of template fields for you, pretty cool! On the left side of the Zap, click the (+) icon and add a Filter:

Add Zapier filter

We want to only send the Zap if the alert has been "Activated" (not if it gets Resolved). Chances are, you only care that the alert occurred and after that you can check your email/fix the issue to resolve it.

Filter for Activated

Now, add an Action to send an SMS (or really, do whatever you want--I just want a text message).

SMS action

You can use the template fields if you want, but this webhook is customized for our alert so I don't really need any info from the alert. If you were sending multiple alerts to this single hook, you could use the fields of the JSON payload to customize the message here.

I am setting a "From number" because I can use an app like FireAlarm2 to read my SMS and page me loudly (even if my phone is on vibrate).

That's it! You can test the Zap and it'll send you an SMS to verify you can receive messages. Now you'll always know when your site's down so you don't need to rely on your users.

Enjoying these posts? Subscribe for more