Bring Alerts to You With Webhooks
Webhooks are like a secret backchannel to internet apps. They are a universal way to connect one thing to another, as long as you meet some important requirements:
- A service to pull data from
- A place to receive the data pulled
- A middleman to translate the data
Uptime.com uses webhooks, but we call them a Custom Postback URL. We use this nomenclature because the URL we need receives a POST, or a REST API POST request, containing data you’ve requested.
With a custom postback URL, you can send Uptime metrics, alerts and technical data to the dashboard of your choosing. This article will dive into the how, and try and answer a bit of the why.
Integrations and Webhooks
Integrations allow Uptime.com users to send information from Uptime.com to another place, such as Geckoboard, Jira Service Desk, VictorOps, or Slack. These integrations function like self-contained webhooks, designed to work out the middleman part for you. Once configured, all you see is metrics in the dashboard you choose.
Webhooks work the same way but you need to instruct your server on how to receive, understand, and ultimately output (view) the data Uptime.com gives to you. Fortunately, we have a very easy structure to work with that looks like the example below:
[check_url] => http://website.com
[check_type] => HTTP(S)
[server_name] => website.com
[check_name] => website.com
[locations] => Array
 => USA
[check_uptime_api_url] => /api/v1/monitoring-checks/6257/
[check_id] => 6257
[date] => Aug. 18, 2015, 6:40 p.m.
[state] => ‘UP’ or ‘DOWN’
[output] => Zero Bytes Received
This JSON serialized string represents data from Uptime.com. Everything is pretty clearly named, so you can easily pick out the check type or the locations, for example.
The important part is what comes next.
Configuring a Webhook
For this example, we’ll use RequestBin. It can provide the endpoint we need to demonstrate a working example without investing in a lot of resources. Always good to test first.
First, generate an endpoint URL by clicking the big green button on the RequestBin page. You can send a test request to get an idea of the data you can expect to see if you’ve never done something like this before.
Next, let’s head to Uptime.com and configure our Custom Postback URL with the endpoint we just received. Paste it into the URL field, and name your integration like so:
Next, head over to Contacts and make sure this URL is assigned as a contact so it can receive data.
Don’t forget to test your integration to see that it it works:
Nice! We found some early success:
And we’ve got an idea of what our data will look like when it’s returned. You can see that much of these values are very easy to understand.
Now that we have our webhook configured and tested, let’s fail a check!
Here’s some sample output to examine. In it, we can see some important information like whether the check is paused, a timestamp for the alert, the number of locations and more.
We’ve established how a Custom Postback URL functions and we’ve examined the data it outputs. What’s next? The sky’s the limit, friends. But, there are a few concepts to be aware of.
You can’t notice any activity because my example isn’t from a live streamed video, but the eagle eyed among you might see that I only received an alert when the check failed.
Webhooks don’t provide continuous monitoring. That’s our job at Uptime.com. In this instance, the webhook you’ve created is telling you what went wrong. Each field is like a database entry, all related to your check, which tells you more about the alert. You can find the alert ID, and the full output for technical analysis.
If you can translate this data into a format your server understands, you can graph alerts or send notifications from within your own internal dashboards. With only a small effort, you can configure Uptime.com to work seamlessly within your own systems and adjust reporting to fit your needs.
Webhooks don’t “just work” like a standard integration. You must create and maintain your own space to receive and output the data, but they do provide near limitless options for configuration.
Get hooked on webhooks and create customized reporting that is responsive and contains only the data you need in an emergency.
Minute-by-minute Uptime checks.
Start your 21-day free trial with no credit card required at Uptime.com.