REST Monitoring

From AlertFox Website Monitoring

Jump to: navigation, search

This page is no longer maintained. Current version is at API Monitoring


Consuming RESTful HTTP/XML APIs With AlertFox Sensors


AlertFox does not have a dedicated REST Monitoring sensor yet, but you can use the HTTP Sensor and its powerful keyword check feature to monitor REST (RESTful) and SOAP services.


It is possible to use data from REST-like APIs as sensor data in AlertFox. The sensor requests data from an HTTP or HTTPS URL (using GET), parses the XML results and uses selected data from the XML as sensor value in AlertFox. With this technique you can import data from many APIs into AlertFox, as long as they are offering an interface that works with simple HTTP GETs and replies with XML data. Services like these are often called “REST APIs or RESTful APIs”. This type of API is becoming more and more common.

The main application we see for this is sensor is to

  • Monitor your own APIs for uptime and performance

But you can also use other public API as input:

  • Monitor current weather conditions using Google.com (see example below), Wheatherbug.com, and www.weather.com, in order to control our datacenter cooling system by tracking outside and inside temperatures.
  • Monitor the ranking of your domain on Compete.com

The only tricky part about this sensor is to supply the necessary URL parameters for the sensor. It requires a good knowledge of the API and the XML output.


REST Example:

Contents

REST Examples

Monitoring Outdoor Temperatures using Free Data from iGoogle

Using the following URL you can get weather data from Google (it seems to be a part of iGoogle):

 http://www.google.com/ig/api?weather=Portland

It returns date like this:

 <?xml version="1.0"?>
 -<xml_api_reply version="1">-<weather section="0" row="0" mobile_zipped="1" mobile_row="0" tab_id="0" module_id="0">
 -<forecast_information>
     <city data="Portland, OR"/>
      <postal_code data="portland"/>
      <latitude_e6 data=""/><longitude_e6 data=""/>
      <forecast_date data="2011-05-22
   ...


You can now use the keyword feature of our HTTP Sensor to verify that the API returns the correct data. In that example, you can for example check for the word "portland" in the response. => See the RESTful API (iGoogle) sensor in our demo account.

As you have seen a classic sensor is normally sufficient for monitoring REST APIs, but you can also use the browser based iMacros sensors:

 URL GOTO=http://www.google.com/ig/api?weather=portland
 TAG POS=1 TYPE=SPAN ATTR=TXT:Portland,<SP>OR
Monitoring RESTful API with a web browser.

This macro checks for the word portland in the response (run in iMacros Browser or Internet Explorer, iMacros for Firefox does not yet support working with XML responses).

Alternatively you can use iMacros's relative positioning to check (extract) exactly a specific attribute of the response:

 URL GOTO=http://www.google.com/ig/api?weather=portland
 TAG POS=1 TYPE=SPAN ATTR=TXT:*city*
 TAG POS=R2 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
Check a specific attribute of the XML response with Internet Explorer.

Display a list of invoices

REST Result:

   <?xml version="1.0" encoding="UTF-8" ?> 
 - <INVOICEList xmlns:xlink="http://www.w3.org/1999/xlink">
   <INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/37/">37</INVOICE> 
   <INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/52/">52</INVOICE> 
   <INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/99/">99</INVOICE> 
   </INVOICEList>

Thus the keyword for your "REST Sensor" (based on the AlertFox HTTP Sensor) can be for example the word INVOICE or 99 (if you want to check for a certain invoice.

See Also

Creating checks for RESTful APIs is part of our free macro creation service.

Personal tools
home
Toolbox

Website Monitoring