Get Monitors

Last modified on July 26, 2024

The Get Monitors operation returns all existing monitors or just those matching the specified query parameters.

Request URL

GET https://api.alertsite.com/api/v3/monitors[?parameters]

Authentication

The request must include the Authorization header containing a user’s access token:

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

Query parameters

Query parameters are optional, but can be used to filter the results.

type

String. The type of the monitors to get or a comma-separated list of monitor types. You can specify multiple types separated by commas, for example, type=dejaclick,api. If not specified, all monitors are returned.

Accepted values:

Value Monitor Type

api

SoapUI API monitor

bitbar

Bitbar monitor

dejaclick

Real-browser or mobile web monitor (DéjàClick)

email-imap

Email server (IMAP) monitor

email-pop

Email server (POP) monitor

email-round-trip

Round-trip email monitor

email-smtp

Email server (SMTP) monitor

ftp

FTP monitor

ftp-ssl

FTPS (FTP over SSL) monitor

name-server

DNS (Name Server) monitor

ping

Ping monitor

selenium

Selenium monitor

serveragent

ServerAgent

tcp

TCP monitor

website

Web URL monitor

website-api

API endpoint monitor

website-ssl

Web URL monitor for https:// URLs

website-ssl-api

API endpoint monitor for https:// endpoints

show_scripts

Boolean. If true, the response includes the contents of DéjàClick, Selenium, and SoapUI files used by the monitors. This allows you to export the files to your computer.

The Default value is false, meaning the file contents are not included in the response.

DéjàClick and SoapUI

DéjàClick scripts and SoapUI projects are XML files. The response’s script field contains the text contents of the XML file encoded as a JSON string. That is, the " \ characters and characters with codes less than 32 (new lines, tabs, and others) are backslash-escaped. For example, the field value:

"script": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<con:soapui-project id=\"e0b0c87d-7b83-4689-945a-18c250254943\" ... </con:soapui-project>"

decodes to

<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project id="00e97f3f-a3b4-4c6f-a61b-0c8aca654746" ...
...
</con:soapui-project>

There are JSON libraries for many programming languages that can decode JSON strings into regular strings.

Selenium

The response’s script field is the base64-encoded contents of a JAR file.

show_script_children

Boolean. If true, the response includes a separate record for each DéjàClick ContentView.

has_sla

Boolean. If set to true, only the monitors with SLAs are returned.

limit

Integer. The maximum number of results to return. Use together with offset to paginate through a large number of results.

offset

Integer. Return the results starting from this offset (0-based).

select

String. A comma-separated list of data fields to return in the response. The field names are case-sensitive. Unrecognized field names are ignored.

If this parameter is omitted, all fields are included. Note that select= with an empty value is not the same as an omitted parameter, and means no fields will be returned.

For more information, see Filter response fields.

For a list of field names that can be used in the select parameter, see Monitor Object.

Response body

The response body is an object containing metadata and results, where results is an array of Monitor objects.

{
  "metadata": {
    "__permissions": {
      "acl": 7
    },
    "resultset": {
      "count": 1,
      "limit": null,
      "offset": null
    }
  },
  "results": [
    {
      <!-- SoapUI monitor example -->

      "access_type": "Edit",
      "alert_note": "Something went wrong",
      "allow_internal_testing": true,
      "billing_plancode": "UBM - A/A",
      "blackout_ids": [
        "1964776"
      ],
      "capture": {
        "headers": true,
        "images": true,
        "level": "Error Only",
        "mimetype": "image/jpeg",
        "sources": true
      },
      "custom_properties": [],
      "customer_id": 35531,
      "enabled": true,
      "has_active_performance_alerts": false,
      "has_performance_alerts": false,
      "has_sla": false,
      "home_location": 10,
      "id": 505774,
      "interval": 120,
      "is_transaction": true,
      "locations": [
        {
          "id": 10,
          "name": "Fort Lauderdale, FL",
          "region": 1
        },
        {
          "id": 42,
          "name": "Los Angeles, California - Level3",
          "region": 1
        },
        {
          "id": 40,
          "name": "Washington, D.C.",
          "region": 1
        }
      ],
      "mode": "Global Verify",
      "monitor_agent": null,
      "monitor_location_count": 1,
      "monitor_uses_own_locations": false,
      "name": "Swagger Petstore",
      "note": "Maintenance is scheduled for the next weekend",
      "notify_on_error": true,
      "project_name": "Swagger Petstore",
      "project_password": "",
      "replay_success": false,
      "retry_on_failure": true,
      "rotate_locations": true,
      "script": "",
      "script_id": null,
      "sla_id": null,
      "ssl_cert_format": "PKCS #12",
      "ssl_cert_id": 1,
      "ssl_cert_name": "AlertSite Certificate",
      "subtype": 0,
      "subtype_application": null,
      "subtype_name": null,
      "test_case": "Petstore Test",
      "test_suite": "Petstore TestSuite",
      "transaction_steps": 3,
      "transaction_steps_allowed": 50,
      "transaction_trace": true,
      "type": "api",
      "use_client_ssl_cert": true,
      "use_ssl_version": "3"
    }
  ]
}

If no monitors matching the specified criteria are found, the response contains an empty results array:

{
  "metadata": {
    "__permissions": {
      "acl": 7
    },
    "resultset": {
      "count": 0,
      "limit": null,
      "offset": "0"
    }
  },
  "results": []
}

Error responses have HTTP status codes in the 4xx range.

Try it out

Click here to test this operation in AlertSite’s interactive API console.

Code examples

cURL

Get all monitors:

curl -X GET https://api.alertsite.com/api/v3/monitors -H "Authorization: Bearer ACCESS_TOKEN"

Get SoapUI and API endpoint monitors:

curl -X GET "https://api.alertsite.com/api/v3/monitors?type=api,website-api,website-ssl-api" -H "Authorization: Bearer ACCESS_TOKEN"

Get monitors with SLAs:

curl -X GET "https://api.alertsite.com/api/v3/monitors?has_sla=true" -H "Authorization: Bearer ACCESS_TOKEN"

Get all monitors, but filter out the response to include the monitor name and type, run interval, monitoring mode, and locations:

curl -X GET "https://api.alertsite.com/api/v3/monitors?select=name,type,interval,mode,locations" -H "Authorization: Bearer ACCESS_TOKEN"

Python

This code outputs all monitors and their names, types, running modes, intervals, and locations.

Python

import requests # Requests library – http://docs.python-requests.org/
import pandas # Pandas library – https://pandas.pydata.org/
import json

baseUrl = 'https://api.alertsite.com/api/v3'
username = '[email protected]'  # Replace with your AlertSite login email
password = 'pa55w0rd'          # Replace with your AlertSite password
payload = {'username': username, 'password': password}
r = requests.post(baseUrl + '/access-tokens', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
token = r.json()['access_token']

# Get all monitors
r = requests.get(baseUrl + '/monitors', headers={'Authorization': 'Bearer ' + token})
result = r.json()

if r.status_code == requests.codes.ok:

    # Use Pandas to output the results as a table
    data_frame = pandas.DataFrame(result['results'], columns=['name', 'type', 'interval', 'mode', 'locations'])

    # Truncate monitor names and locations to fit the display
    data_frame['name'] = data_frame['name'].str[:30]
    data_frame['locations'] = data_frame['locations'].str[:6]

    with pandas.option_context('display.max_rows', None, 'display.max_columns', None, 'display.width', 200):
        print(data_frame)
else:
    print('Could not get the monitors. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Monitor Operations
Get Monitor by ID
Delete Monitor

Highlight search results