12/12/2011

Callback URLs Explained

You know you get automatically notified when your device or service goes down. But did you know you can have certain functions performed automatically, perhaps evening restoring service without intervention? The Alertra monitoring service supports this feature with a callback URL.

What exactly is a callback URL? In a field filled with complicated and confusing terms, a callback URL is, surprisingly, just what it says it is. "Callback" refers to the computer programming practice of sending executable code to another function, routine, or program. It can be a powerful technique allowing totally dynamic behavior (that means it can do different things with the same computer code). On the web the term has become a callback URL because it "calls back" a web address rather than a bit of code.

Here's a common example of how a callback works - something that most people who've bought online probably have experienced. You've made a purchase on your favorite website and clicked the "Submit" button. Chances are you'll be sent to an external service that handles the payment processing (like PayPal) where you confirm your order, or just wait while you watch the word "processing..." blink on the screen. After the transaction completes you are directed back to the original shopping site. The page that you see is the callback URL. Though you didn't know it, you left your favorite online store's website during the processing, and the external site you visited returned you back to it. Barring any glitches you should see the page the store wanted you to see after an order. It might be a thank you page, or other page with order confirmation information, next steps, or their home page. It may vary depending on what you ordered, when you ordered, and how you ordered.

Basically a callback URL gives directions to an external system on where to go next. What is at that URL could be anything. It doesn't have to be a static URL. Often it is a script to perform certain functions. When it comes to detecting an outage via Alertra that means you can have pre-scripted instructions set to go, as well as being notified via SMS or email. The script can be as simple as recording the event in an external system log, or something more complicated like stopping and restarting services that went down.

Alertra added this feature so that their customers can use this in their own development and maintenance programs for their monitored systems.

If you want to know more about how to set this up in your Alerta account check out this article that contains detailed information on the parameters and sample code to use. While there, be sure to check out our other articles on Alertra features and examples on how to use them.