Alertra REST API

[API Documentation] (Did you know you can earn $100 for writing an Alertra API tutorial?) Take control of your monitoring and your data using our secure HTTP-based API. Send and receive data in JSON format (receive XML if you need it). The API supports the HTTP GET, POST, PUT and DELETE methods.

  • Suspend monitoring automatically when your server backup starts.
  • Set up new devices for monitoring.
  • Download very detailed check data.
  • Get uptime statistics for any timeframe.
  • If you need something the API doesn't do, just ask.

Of course you can use the programming environment of your choice, but check out these examples using Python and the Requests library.

Automate Maintenance

Stop and restart maintenance for your monitored device as part of your own internal maintenance systems. Does your server go down regularly for backup? Why not build monitoring maintenance into the process so you don't receive alerts when you don't want them and as soon as your backup completes, we start monitoring again.

>>> import json
>>> import requests
>>> url = 'https://api.alertra.com/v1.1/devices/<YOUR-DEVICE-ID>/start-maintenance'
>>> payload = {'Duration': '02:00'}
>>> headers = {'Alertra-API-Key': '<YOUR-API-KEY>', 'Content-Type': 'application/json'}
>>> r = requests.put(url, data=json.dumps(payload), headers=headers)
>>> r.status_code
200

Get Uptime Statistics

Calculate uptime your way using custom timeframes and your own formula.

>>> import requests
>>> url = 'https://api.alertra.com/v1.1/devices/<DEVICE_ID>/uptime?Timestamp1=2014-01-01T00:00:00'
>>> headers = {'Alertra-API-Key': '<YOUR-API-KEY>'}
>>> r = requests.get(url, headers=headers)
>>> r.json()
{
  "Uptime" : {
    "UpSeconds" : 3600941,
    "DownSeconds" : 386,
    "MaintenanceSeconds" : 0,
    "Outages" : 1
  }
}

Get Check Data

Get detailed check data. Analyze the times in each phase of the HTTP request/response. Store the data for later analysis.

>>> import requests
>>> url = 'https://api.alertra.com/v1.1/devices/<YOUR-DEVICE-ID>/checks?Limit=1'
>>> headers = {'Alertra-API-Key': '<YOUR-API-KEY>'}
>>> r = requests.get(url, headers=headers)
>>> r.json()
[
  {
    "PerfStat" : "Ok",
    "TTFB" : 0,
    "BlockTime" : 0,
    "RequestTime" : 3520.77392578125,
    "Kbps" : 0,
    "Location" : "Stockholm SWE",
    "ConnectTime" : 0,
    "Timestamp" : "2014-02-11T20:30:37-05:00",
    "SSLTime" : 0,
    "ResultCode" : 1,
    "DataSize" : 0,
    "DNSTime" : 0,
    "TTLB" : 3520.77,
    "check_id" : "<CHECK_ID>"
  }
]