Monthly Archives: December 2013

Create a Dashboard with the REST API

Viewing your monitors is fairly simple on MxToolBox’s website, but wouldn’t it be nice to have your monitor status on your website? This post shows off a sample dashboard using HTML, Javascript, and the REST API we talked about in our previous blog post and on our websiteYou can view the sample or download the files

Breaking Down the Sample – How It Works

Note that this sample is using the sample API Key, which can only query “example.com.”  You will need to use your own api key within sample.js.  Search for “add your api key here, ” use your api key, and you are running.

dashboard
The mechanics start with calling the Monitor API to get the status, then it’s mostly a matter of formatting.  This api will return each of your monitors’ status:

  {
    "MonitorUID": "e442d19c-5746-4816-b5af-65624757c297",
    "ActionString": "blacklist:example.com",
    "LastTransition": "2009-11-03T06:15:34.867",
    "LastChecked": "2013-12-02T15:23:35.78",
    "MxRep": "100",
    "Failing": [],
    "Warnings": []
  },

This javascript is composed of the following frameworks –

On DocumentLoad, we use the monitor details to determine the status of the monitor based on the problems listed in “Failing” and “Warnings.”  We then pass that jsRender to create a nicely formatted table.

Extend the Dashboard with Tags

Some customers segment their monitors by tagging them.  You can use the monitor API to query by tags by adding a ‘tag’ querystring parameter to the api.  The link below gets only the example.com monitors that have the “blacklist” tag:

http://api.mxtoolbox.com/api/v1/monitor/?authorization={your_api_key_goes_here}&tag=blacklist

One customer uses the tag filter to create dashboards for each of his regions, and another uses it to show only his blacklist monitors.

Learn more about the REST API