Getting Data

Last updated on 19 April, 2024

You can use LogicMonitor REST API v3 to get data. You must authenticate yourself before making the API request.

Common Query Parameters

The following query parameters are common to all GET requests for Data APIs. 

ParameterTypeDescription
startIntegerThe start time (in epoch seconds) for returned data. It defaults to the selected graph time range.
endIntegerThe end time (in epoch seconds) for returned data. It defaults to the selected graph time range.
formatStringdata | image | csv – Specify whether the returned data must be formatted as a number value (data = json) or an image. It defaults to data.

Getting Device Instance Data

By default, data is returned for the last hour.

URI: GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/data

Note: The query parameters: start, end, and format must be included while making the request GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/data. For details, see the common query parameters table.

Additional parameters deviceIdhdsIdidperiod, and datapoints which are specific to GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/data are described in the following table.

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
idInteger(Mandatory) The instance ID.
periodNumberThe number of hours data must be returned, ending at the current time. For example, period=2 means last 2 hours.
datapointsStringThe datapoints associated with the datasource for which data must be returned.

Example

The following Python script returns the last two hours of data for device ID 533, device datasource ID 12506, and instance ID 23.

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass

#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'  
 
#Request Info
httpVerb ='GET'
resourcePath = '/device/devices/533/devicedatasources/12506/instances/23/data'
queryParams = '?period=2'
data = ''
 
#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 + data + resourcePath  
 
#Construct signature digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8') 
  
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}  
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Getting Device Instance Graph Data

By default, data is returned for the configured graph time range.

URI: GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data

Note: The query parameters: start, end, and format must be included while making the request GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data. For details, see the common query parameters table.

Additional parameters deviceIdhdsIdid, and graphId which are specific to GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data are described in the following table.

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
idInteger(Mandatory) The instance ID.
graphIdInteger(Mandatory) The graph ID to get graph data.

Example

The following Python script gets data from 1482865561 to 1482865719 for graph ID 253 which is associated with the instance ID 26657295, datasource ID 6842, and device ID 258.

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass

#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'  
 
#Request Info
httpVerb ='GET'
resourcePath = '/device/devices/258/devicedatasources/6842/instances/26657295/graphs/253/data'
queryParams ='?start=1482865561&end=1482865719'
data = ''
 
#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 + data + resourcePath  
 
#Construct signature digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8') 
  
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Getting Device Instance Group Overview Graph Data

URI: GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data

Note: The query parameters: start, end, and format must be included while making the request GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data. For details, see the common query parameters table.

Additional parameters deviceIddeviceDsIddsigId, and ographId which are specific to GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data are described in the following table.

ParameterTypeDescription
deviceIdInteger(Mandatory) The ID of the device to get data.
deviceDsIdInteger(Mandatory) The ID of the device datasource.
dsigIdInteger(Mandatory) The ID of the instance group for which you want to get overview graph data.
ographIdInteger(Mandatory) The ID of the overview graph whose data you want to get.

Getting Device Instance Graph Data

By default, data is returned for the configured graph time range.

URI: GET /device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data

Note: The query parameters: start, end, and format must be included while making the request GET /device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data. For details, see the common query parameters table.

Additional parameters instanceId and graphId which are specific to GET /device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data are described in the following table.

ParameterTypeDescription
instanceIdInteger(Mandatory) The ID of the device datasource instance to get graph data.
graphIdInteger(Mandatory) The ID of the graph to get graph data.

Example

The following Python script saves an image file ‘instanceGraph.png’ for graph ID 4825 which is associated with the device datasource instance ID 420576596.

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass

#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'   
 
#Request Info
httpVerb ='GET'
resourcePath = '/device/devicedatasourceinstances/420576596/graphs/4825/data'
queryParams = '?format=image'
data =''
 
#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 + data + resourcePath  
 
#Construct signature digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8') 
  
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}  
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and write image data to a png file
print('Response Status:',response.status_code)
file_ = open('instanceGraph.png', 'wb')
file_.write(response.content)
file_.close()
Python 3

Getting Website Graph Data

By default, data is returned for the configured graph time range.

URI: GET /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data

Note: The query parameters: start, end, and format must be included while making the request GET /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data. For details, see the common query parameters table.

Additional parameters websiteIdcheckpointId, and graphName which are specific to GET /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data are described in the following table.

ParameterTypeDescription
websiteIdInteger(Mandatory) The ID of the website to get checkpoint details.
checkpointIdInteger(Mandatory) The ID of the checkpoint to get graph data.
graphNameString(Mandatory) The name of the graph to get data where possible values are statusperformance (only for individual checkpoints), and responsetime.

Example

The following Python script requests performance graph data from 1482865561 to 1482865719 for website ID 58, checkpoint ID 294, and graph name performance.

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass

#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'   
 
#Request Info
httpVerb ='GET'
resourcePath = '/service/services/58/checkpoints/294/graphs/performance/data'
queryParams ='?start=1482865561&end=1482865719'
data = ''
 
#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 + data + resourcePath  
 
#Construct signature digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8') 
  
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}  
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Getting Data for Website Checkpoint

By default, data is returned for the last hour.

URI: GET /website/websites/{srvId}/checkpoints/{checkId}/data

Note: The query parameters: start, end, and format must be included while making the request GET /website/websites/{srvId}/checkpoints/{checkId}/data. For details, see the common query parameters table.

Additional parameters srvIdcheckId, period, datapoints, and aggregate which are specific to GET /website/websites/{srvId}/checkpoints/{checkId}/data are described in the following table.

ParameterTypeDescription
srvIdInteger(Mandatory) The ID of the website.
checkIdInteger(Mandatory) The ID of the service checkpoint to get data.
periodNumberThe number of hours for which data must be returned.
datapointsStringThe datapoints associated with the website for which data is returned.
aggregateStringAvailable values are – firstlastminmaxsumaverage, and none. The default value is none.

Example

The following Python script gets data from 1482865561 to 1482865719 for website ID 58 and checkpoint ID 294.

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass

#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'   
 
#Request Info
httpVerb ='GET'
resourcePath = '/website/websites/58/checkpoints/294/data'
queryParams ='?start=1482865561&end=1482865719'
data = ''
 
#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 + data + resourcePath  
 
#Construct signature digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8') 
  
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}  
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Getting Widget Data

This data resource does not work for text, HTML, and flash widgets.

  • For widgets without time series data, such as the map widget and the alert widget, data is returned based on what is displayed in the widget (locations and matching alerts) independent of time.
  • For widgets with time series data, such as the custom graph widget and the device graph widget, data is returned based on the time range configured or specified in the request.

The response may contain additional attributes depending on the widget type. For details, refer the models corresponding to specific widget type given at the end of this page.

URI: GET /dashboard/widgets/{id}/data

Note: The query parameters: start, end, and format must be included while making the request GET /dashboard/widgets/{id}/data. For details, see the common query parameters table.

An additional parameter id which is specific to GET /dashboard/widgets/{id}/data is described in the following table.

ParameterTypeDescription
idInteger(Mandatory) The ID of the widget to get data.

Example

The following Python script gets data from 1482865561 to 1482865719 for widget 362.

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass

#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
 
#Request Info
httpVerb ='GET'
resourcePath = '/dashboard/widgets/362/data'
queryParams ='?start=1482865561&end=1482865719'
data = ''
 
#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 + data + resourcePath  
 
#Construct signature digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8') 
  
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3
In This Article