REST API Developer's Guide

Get Websites

You can use LogicMonitor's REST API to programmatically get information about your LogicMonitor websites. You can either get a list of websites or you can get details for a particular website.

Note that scripted web checks will not be returned via v1 of the REST API, and that you should use v2 to get and manage these resources.

 

Get a list of Websites

Returns a list of websites

HTTP Method: GET

URI: /service/services

Request Parameters: By default, a list of 50 services will be returned. You can include sort, filter, fields, size and offset parameters in your request to control what data is included in the response and how it is formatted. Note that query parameters are not considered part of the resource path, and should not be included the calculation of the LMv1 authentication signature.

Property

Syntax

Description

Example URI

sortsort={+ or -}propertySorts the response by the property specified in either increasing (+) or decreasing (-) order/service/services?sort=-id
filterfilter=property{operator}value Filters the response according to the operator and value specified. Note that you can use * to match on more than one character.You can use the '.' character to filter values within an object (e.g. custom properties), and multiple filters can be separated by a comma.

Operators include:
  • Greater than or equals: >:
  • Less than or equals: <:
  • Greater than: >
  • Less than: <
  • Does not equal: !:
  • Equals: :
  • Includes: ~
  • Does not include: !~
/service/services?filter=name:QAservice
fieldsfields={list of properties separated by commas} Filters the response to only include the following fields for each object/service/services?fields=name,id
sizesize=integerThe number of results to display. Max is 1000./service/services?size=5
offsetoffset=integerThe number of results to offset the displayed results by/service/services?offset=2

 

Get information about a particular website

Returns details for a particular website

HTTP Method:GET

URI: /service/services/{id}

Request Parameters: You can include a filter parameter that controls which properties are displayed in the response:

Property

Syntax

Description

Example URI

fieldsfields={list of properties separated by commas} Filters the response to only include the following fields for each object/service/services/{id}?fields=name,id

 

Examples

Example 1: GET all Websites

The following Python script returns a list of all services in the api.logicmonitor.com portal. 

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='J62te62B8u7WnCR846h6'
AccessKey ='{[H^LX=^Zg^32yp-x(-2Bq22vZ~^u-k3)8!9[7U^'
Company = 'api'

#Request Info: Get Services
httpVerb ='GET'
resourcePath = '/service/services'

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath 

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + resourcePath

#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, headers=headers)

#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content

Output:

{
  "status" : 200,
  "errmsg" : "OK",
  "data" : {
    "total" : 5,
    "items" : [ {
      "type" : "webservice",
      "id" : 58,
      "name" : "Form-based auth",
      "description" : "",
      "serviceFolderId" : 1,
      "stopMonitoring" : false,
      "stopMonitoringByFolder" : false,
      "disableAlerting" : false,
      "individualSmAlertEnable" : false,
      "individualAlertLevel" : "warn",
      "overallAlertLevel" : "warn",
      "alertStatus" : "none",
      "sdtStatus" : "none-none-none",
      "alertDisableStatus" : "none-none-none",
      "pollingInterval" : 10,
      "transition" : 1,
      "testLocation" : "{\"smgIds\":[3],\"all\":false}",
      "globalSmAlertCond" : 0,
      "useDefaultLocationSetting" : false,
      "useDefaultAlertSetting" : false,
      "userPermission" : "write",
      "checkpoints" : [ {
        "id" : 292,
        "geoInfo" : "Overall",
        "smgId" : 0
      }, {
        "id" : 294,
        "geoInfo" : "US - San Francisco",
        "smgId" : 3
      } ],
      "serviceProperties" : [ ],
      "steps" : [ {
        "HTTPHeaders" : "",
        "statusCode" : "",
        "followRedirection" : true,
        "matchType" : "plain",
        "keyword" : "",
        "HTTPBody" : "",
        "HTTPMethod" : "GET",
        "postDataEditType" : "raw",
        "label" : "",
        "url" : "test.logicmonitor.com/santaba/",
        "fullpageLoad" : false,
        "requireAuth" : false,
        "auth" : null,
        "invertMatch" : false,
        "timeout" : 30,
        "HTTPVersion" : "1.1",
        "schema" : "https",
        "description" : "",
        "path" : "",
        "enable" : true,
        "name" : "__step0",
        "domain" : "test.logicmonitor.com"
      }, {
        "HTTPHeaders" : "Content-Type:application/x-www-form-urlencoded",
        "statusCode" : "",
        "followRedirection" : true,
        "matchType" : "plain",
        "keyword" : "",
        "HTTPBody" : "c=test&u=testp=test",
        "HTTPMethod" : "POST",
        "postDataEditType" : "raw",
        "label" : "",
        "url" : "test.logicmonitor.com/santaba/",
        "fullpageLoad" : false,
        "requireAuth" : false,
        "auth" : null,
        "invertMatch" : false,
        "timeout" : 30,
        "HTTPVersion" : "1.1",
        "schema" : "https",
        "description" : "",
        "path" : "data.status",
        "enable" : true,
        "name" : "__step1",
        "domain" : "test.logicmonitor.com"
      }, {
        "HTTPHeaders" : "",
        "statusCode" : "",
        "followRedirection" : true,
        "matchType" : "plain",
        "keyword" : "sarah",
        "HTTPBody" : "",
        "HTTPMethod" : "GET",
        "postDataEditType" : "raw",
        "label" : "",
        "url" : "test.logicmonitor.com/santaba/uiv3/device/index.jsp#layer/dg/1/info",
        "fullpageLoad" : true,
        "requireAuth" : false,
        "auth" : null,
        "invertMatch" : false,
        "timeout" : 30,
        "HTTPVersion" : "1.1",
        "schema" : "https",
        "description" : "",
        "path" : "",
        "enable" : true,
        "name" : "__step2",
        "domain" : "test.logicmonitor.com"
      } ],
      "script" : "",
      "method" : "tabledriven",
      "ignoreSSL" : false,
      "pageLoadAlertTimeInMS" : 30000
    }, {
      "type" : "webservice",
      "id" : 41,
      "name" : "Multi-Step",
      "description" : "",
      "serviceFolderId" : 11,
      "stopMonitoring" : false,
      "stopMonitoringByFolder" : false,
      "disableAlerting" : false,
      "individualSmAlertEnable" : false,
      "individualAlertLevel" : "warn",
      "overallAlertLevel" : "warn",
      "alertStatus" : "unconfirmed-warn",
      "sdtStatus" : "none-none-none",
      "alertDisableStatus" : "none-none-none",
      "pollingInterval" : 1,
      "transition" : 1,
      "testLocation" : "{\"all\":true}",
      "globalSmAlertCond" : 0,
      "useDefaultLocationSetting" : false,
      "useDefaultAlertSetting" : false,
      "userPermission" : "write",
      "checkpoints" : [ {
        "id" : 204,
        "geoInfo" : "Overall",
        "smgId" : 0
      }, {
        "id" : 208,
        "geoInfo" : "Asia - Singapore",
        "smgId" : 5
      }, {
        "id" : 207,
        "geoInfo" : "Europe - Dublin",
        "smgId" : 4
      }, {
        "id" : 205,
        "geoInfo" : "US - San Francisco",
        "smgId" : 3
      }, {
        "id" : 203,
        "geoInfo" : "US - Washington DC",
        "smgId" : 2
      } ],
      "serviceProperties" : [ ],
      "steps" : [ {
        "HTTPHeaders" : "",
        "statusCode" : "",
        "followRedirection" : false,
        "matchType" : "plain",
        "keyword" : "",
        "HTTPBody" : "",
        "HTTPMethod" : "GET",
        "postDataEditType" : "raw",
        "label" : "step 1",
        "url" : "kittens.test.logicmonitor.com/morekittens.html",
        "fullpageLoad" : true,
        "requireAuth" : false,
        "auth" : null,
        "invertMatch" : false,
        "timeout" : 30,
        "HTTPVersion" : "1.1",
        "schema" : "http",
        "description" : "",
        "path" : "",
        "enable" : true,
        "name" : "__step0",
        "domain" : "kittens.test.logicmonitor.com"
      } ],
      "script" : "",
      "method" : "tabledriven",
      "ignoreSSL" : true,
      "pageLoadAlertTimeInMS" : 30000
    }, {
      "type" : "ping",
      "id" : 60,
      "name" : "JIRA",
      "description" : "",
      "serviceFolderId" : 11,
      "stopMonitoring" : false,
      "stopMonitoringByFolder" : false,
      "disableAlerting" : false,
      "individualSmAlertEnable" : true,
      "individualAlertLevel" : "critical",
      "overallAlertLevel" : "critical",
      "alertStatus" : "unconfirmed-critical",
      "sdtStatus" : "none-none-none",
      "alertDisableStatus" : "none-none-none",
      "pollingInterval" : 5,
      "transition" : 1,
      "testLocation" : "{\"smgIds\":[1,2,3,4,5],\"all\":true}",
      "globalSmAlertCond" : 0,
      "useDefaultLocationSetting" : true,
      "useDefaultAlertSetting" : false,
      "userPermission" : "write",
      "checkpoints" : [ {
        "id" : 302,
        "geoInfo" : "Overall",
        "smgId" : 0
      }, {
        "id" : 306,
        "geoInfo" : "Asia - Singapore",
        "smgId" : 5
      }, {
        "id" : 305,
        "geoInfo" : "Europe - Dublin",
        "smgId" : 4
      }, {
        "id" : 304,
        "geoInfo" : "US - San Francisco",
        "smgId" : 3
      }, {
        "id" : 303,
        "geoInfo" : "US - Washington DC",
        "smgId" : 2
      } ],
      "serviceProperties" : [ ],
      "count" : 5,
      "host" : "asdfasdfasdfasdf",
      "percentPktsNotReceiveInTime" : 80,
      "timeoutInMSPktsNotReceive" : 500
    }, {
      "type" : "webservice",
      "id" : 49,
      "name" : "LMCertification",
      "description" : "",
      "serviceFolderId" : 12,
      "stopMonitoring" : false,
      "stopMonitoringByFolder" : false,
      "disableAlerting" : false,
      "individualSmAlertEnable" : false,
      "individualAlertLevel" : "warn",
      "overallAlertLevel" : "warn",
      "alertStatus" : "none",
      "sdtStatus" : "none-none-none",
      "alertDisableStatus" : "none-none-none",
      "pollingInterval" : 10,
      "transition" : 3,
      "testLocation" : "{\"smgIds\":[1,4],\"all\":false}",
      "globalSmAlertCond" : 0,
      "useDefaultLocationSetting" : false,
      "useDefaultAlertSetting" : false,
      "userPermission" : "write",
      "checkpoints" : [ {
        "id" : 251,
        "geoInfo" : "Overall",
        "smgId" : 0
      }, {
        "id" : 253,
        "geoInfo" : "Europe - Dublin",
        "smgId" : 4
      } ],
      "serviceProperties" : [ ],
      "steps" : [ {
        "HTTPHeaders" : "",
        "statusCode" : "",
        "followRedirection" : true,
        "matchType" : "plain",
        "keyword" : "LogicMonitor Certification",
        "HTTPBody" : "",
        "HTTPMethod" : "GET",
        "postDataEditType" : "raw",
        "label" : "",
        "url" : "logicmonitor.docebosaas.com/lms/",
        "fullpageLoad" : false,
        "requireAuth" : false,
        "auth" : null,
        "invertMatch" : false,
        "timeout" : 30,
        "HTTPVersion" : "1.1",
        "schema" : "https",
        "description" : "",
        "path" : "",
        "enable" : true,
        "name" : "__step0",
        "domain" : "logicmonitor.docebosaas.com"
      }, {
        "HTTPHeaders" : "Content-Type:application/x-www-form-urlencoded",
        "statusCode" : "",
        "followRedirection" : true,
        "matchType" : "plain",
        "keyword" : "",
        "HTTPBody" : "login_pwd=test&login_user=test",
        "HTTPMethod" : "POST",
        "postDataEditType" : "x-www-form-urlencoded",
        "label" : "",
        "url" : "logicmonitor.docebosaas.com/lms/",
        "fullpageLoad" : false,
        "requireAuth" : false,
        "auth" : null,
        "invertMatch" : false,
        "timeout" : 30,
        "HTTPVersion" : "1.1",
        "schema" : "https",
        "description" : "",
        "path" : "",
        "enable" : true,
        "name" : "__step1",
        "domain" : "logicmonitor.docebosaas.com"
      } ],
      "script" : "",
      "method" : "tabledriven",
      "ignoreSSL" : false,
      "pageLoadAlertTimeInMS" : 20000
    }, {
      "type" : "ping",
      "id" : 48,
      "name" : "LMService",
      "description" : "",
      "serviceFolderId" : 12,
      "stopMonitoring" : false,
      "stopMonitoringByFolder" : false,
      "disableAlerting" : false,
      "individualSmAlertEnable" : false,
      "individualAlertLevel" : "warn",
      "overallAlertLevel" : "warn",
      "alertStatus" : "none",
      "sdtStatus" : "none-none-none",
      "alertDisableStatus" : "none-none-none",
      "pollingInterval" : 5,
      "transition" : 1,
      "testLocation" : "{\"all\":true}",
      "globalSmAlertCond" : 0,
      "useDefaultLocationSetting" : false,
      "useDefaultAlertSetting" : false,
      "userPermission" : "write",
      "checkpoints" : [ {
        "id" : 245,
        "geoInfo" : "Overall",
        "smgId" : 0
      }, {
        "id" : 250,
        "geoInfo" : "Asia - Singapore",
        "smgId" : 5
      }, {
        "id" : 249,
        "geoInfo" : "Europe - Dublin",
        "smgId" : 4
      }, {
        "id" : 248,
        "geoInfo" : "US - San Francisco",
        "smgId" : 3
      }, {
        "id" : 247,
        "geoInfo" : "US - Washington DC",
        "smgId" : 2
      } ],
      "serviceProperties" : [ ],
      "count" : 20,
      "host" : "kittens.test.logicmonitor.com",
      "percentPktsNotReceiveInTime" : 70,
      "timeoutInMSPktsNotReceive" : 300
    } ],
    "searchId" : null
  }

 

Example 2: GET all Websites

The following Python script returns a list of all websites in the api.logicmonitor.com portal, where only the id, name, type, and alertStatus fields are returned for each result and the results are sorted in descending order according to the alertStatus. 

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='J62te62B8u7WnCR846h6'
AccessKey ='{[H^LX=^Zg^32yp-x(-2Bq22vZ~^u-k3)8!9[7U^'
Company = 'api'

#Request Info: Get Services
httpVerb ='GET'
resourcePath = '/service/services'
queryParams = '?fields=id,name,host,alertStatus&sort=-alertStatus'

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath + queryParams

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + resourcePath

#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, headers=headers)

#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content

Output:

{
  "status" : 200,
  "errmsg" : "OK",
  "data" : {
    "total" : 5,
    "items" : [ {
      "type" : "webservice",
      "id" : 58,
      "name" : "Form-based auth",
      "alertStatus" : "none"
    }, {
      "type" : "webservice",
      "id" : 41,
      "name" : "Multi-Step",
      "alertStatus" : "unconfirmed-warn"
    }, {
      "type" : "ping",
      "id" : 60,
      "name" : "JIRA",
      "alertStatus" : "unconfirmed-critical"
    }, {
      "type" : "webservice",
      "id" : 49,
      "name" : "LMCertification",
      "alertStatus" : "none"
    }, {
      "type" : "ping",
      "id" : 48,
      "name" : "LMService",
      "alertStatus" : "none"
    } ],
    "searchId" : null
  }

 

Example 3: GET one website

The following Python script returns the details for the website with id 2. 

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='J62te62B8u7WnCR846h6'
AccessKey ='{[H^LX=^Zg^32yp-x(-2Bq22vZ~^u-k3)8!9[7U^'
Company = 'api'

#Request Info: Get Services
httpVerb ='GET'
resourcePath = '/service/services/2'


#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath 

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + resourcePath

#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, headers=headers)

#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content

Output:

{
  "status" : 200,
  "errmsg" : "OK",
  "data" : {
    "type" : "ping",
    "id" : 2,
    "name" : "JIRA",
    "description" : "",
    "serviceFolderId" : 11,
    "stopMonitoring" : false,
    "stopMonitoringByFolder" : false,
    "disableAlerting" : false,
    "individualSmAlertEnable" : true,
    "individualAlertLevel" : "critical",
    "overallAlertLevel" : "critical",
    "alertStatus" : "unconfirmed-critical",
    "sdtStatus" : "none-none-none",
    "alertDisableStatus" : "none-none-none",
    "pollingInterval" : 5,
    "transition" : 1,
    "testLocation" : "{\"smgIds\":[1,2,3,4,5],\"all\":true}",
    "globalSmAlertCond" : 0,
    "useDefaultLocationSetting" : true,
    "useDefaultAlertSetting" : false,
    "userPermission" : "write",
    "checkpoints" : [ {
      "id" : 302,
      "geoInfo" : "Overall",
      "smgId" : 0
    }, {
      "id" : 306,
      "geoInfo" : "Asia - Singapore",
      "smgId" : 5
    }, {
      "id" : 305,
      "geoInfo" : "Europe - Dublin",
      "smgId" : 4
    }, {
      "id" : 304,
      "geoInfo" : "US - San Francisco",
      "smgId" : 3
    }, {
      "id" : 303,
      "geoInfo" : "US - Washington DC",
      "smgId" : 2
    } ],
    "serviceProperties" : [ ],
    "count" : 5,
    "host" : "test.jira.com",
    "percentPktsNotReceiveInTime" : 80,
    "timeoutInMSPktsNotReceive" : 500
  }

 

Example 4: GET one website

The following Python script returns the id, name, and alertStatus for the website with id 2. 

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='J62te62B8u7WnCR846h6'
AccessKey ='{[H^LX=^Zg^32yp-x(-2Bq22vZ~^u-k3)8!9[7U^'
Company = 'api'

#Request Info: Get Services
httpVerb ='GET'
resourcePath = '/service/services/2'
queryParams = '?fields=id,name,alertStatus'

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath + queryParams

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + resourcePath

#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, headers=headers)

#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content

Output:

{
  "status" : 200,
  "errmsg" : "OK",
  "data" : {
    "id" : 60,
    "name" : "JIRA",
    "alertStatus" : "unconfirmed-critical"
  }