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.
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.
- Sign up for an account
- Create a new Zap
- Select "Webhook by Zapier" as the trigger
- Go through the steps until you get a new 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:
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:
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:
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.
Now, add an Action to send an SMS (or really, do whatever you want--I just want a text message).
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.