Get Monitor by ID

Last modified on March 27, 2024

Get the monitor configuration for the specified monitor ID.

Request URL

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

Authentication

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

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

Parameters

id

Integer. Monitor ID.

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.

download_script

Optional. Boolean. Downloads the monitor script as a zip file. If true, the show_scripts, show_script_children, and select parameters are ignored.

select

String. A comma-separated list of monitor 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 Fields.

Response body

On success, the operation returns HTTP status 200 and a JSON representation of a Monitor object.

{
  "__permissions": {
    "acl": 7
  },

  <!-- SoapUI monitor example -->

  "access_type": "Edit",
  "alert_note": null,
  "allow_internal_testing": true,
  "billing_plancode": "UBM - A/A",
  "blackout_ids": null,
  "capture": {
    "headers": true,
    "images": true,
    "level": "All Steps",
    "mimetype": "image/jpeg",
    "sources": true
  },
  "custom_properties": [],
  "customer_id": 4553,
  "enabled": true,
  "has_active_performance_alerts": false,
  "has_performance_alerts": false,
  "has_sla": false,
  "home_location": 10,
  "id": 269411,
  "interval": 60,
  "is_transaction": true,
  "locations": [
    {
      "id": 5040,
      "name": "Dublin, Ireland",
      "region": 1
    },
    {
      "id": 10,
      "name": "Fort Lauderdale, FL",
      "region": 1
    }
  ],
  "mode": "Global Verify",
  "monitor_agent": null,
  "monitor_location_count": 1,
  "monitor_uses_own_locations": true,
  "name": "Swagger Petstore",
  "note": null,
  "notify_on_error": true,
  "project_name": "Project 1",
  "project_password": "",
  "replay_success": true,
  "retry_on_failure": true,
  "rotate_locations": true,
  "script": "",
  "script_id": null,
  "sla_id": null,
  "ssl_cert_format": null,
  "ssl_cert_id": null,
  "ssl_cert_name": null,
  "subtype": 0,
  "subtype_application": null,
  "subtype_name": null,
  "test_case": "/pet/findByStatus TestCase",
  "test_suite": "Swagger Petstore TestSuite",
  "transaction_steps": 1,
  "transaction_steps_allowed": 50,
  "transaction_trace": false,
  "type": "api",
  "use_client_ssl_cert": false,
  "use_ssl_version": ""
}

Error responses have a non-200 status code and include the errors list:

{
  "errors": [
    {
      "code": 404,
      "message": "Record not found"
    }
  ]
}

Try it out

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

Code examples

cURL

Get the monitor with ID 1234:

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

Get the monitor with ID 1234, but filter out the response to include the monitor name and type, run interval, monitoring mode, and locations:

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

Download the SoapUI project for monitor 1234:

curl "https://api.alertsite.com/api/v3/monitors/1234?download_script=true" -H "Authorization: Bearer ACCESS_TOKEN"

Python

This code outputs the monitor configuration for monitor ID 1234.

Python

# Python 3.5+
import requests  # Requests library http://docs.python-requests.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
monitor_id = 1234

# Log in
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 the monitor configuration
r = requests.get(baseUrl + '/monitors/{}'.format(monitor_id), headers={'Authorization': 'Bearer ' + token})
if r.status_code == requests.codes.ok:
    print(json.dumps(r.json(), indent=2))
else:
    print('Could not get monitor #{}. The following error(s) occurred:'.format(sla_id), *r.json()['errors'], sep='\n')

See Also

Monitor Operations
Get Monitors

Highlight search results