Getting Data
Last updated on 07 October, 2024You 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.
Parameter | Type | Description |
start | Integer | The start time (in epoch seconds) for returned data. It defaults to the selected graph time range. |
end | Integer | The end time (in epoch seconds) for returned data. It defaults to the selected graph time range. |
format | String | data | 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 deviceId
, hdsId
, id
, period
, and datapoints
which are specific to GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/data
are described in the following table.
Parameter | Type | Description |
deviceId | Integer | (Mandatory) The device ID. |
hdsId | Integer | (Mandatory) The device datasource ID. |
id | Integer | (Mandatory) The instance ID. |
period | Number | The number of hours data must be returned, ending at the current time. For example, period =2 means last 2 hours. |
datapoints | String | The 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)
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 deviceId
, hdsId
, id
, and graphId
which are specific to GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data
are described in the following table.
Parameter | Type | Description |
deviceId | Integer | (Mandatory) The device ID. |
hdsId | Integer | (Mandatory) The device datasource ID. |
id | Integer | (Mandatory) The instance ID. |
graphId | Integer | (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)
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 deviceId
, deviceDsId
, dsigId
, and ographId
which are specific to GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data
are described in the following table.
Parameter | Type | Description |
deviceId | Integer | (Mandatory) The ID of the device to get data. |
deviceDsId | Integer | (Mandatory) The ID of the device datasource. |
dsigId | Integer | (Mandatory) The ID of the instance group for which you want to get overview graph data. |
ographId | Integer | (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.
Parameter | Type | Description |
instanceId | Integer | (Mandatory) The ID of the device datasource instance to get graph data. |
graphId | Integer | (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()
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 websiteId
, checkpointId
, and graphName
which are specific to GET /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data
are described in the following table.
Parameter | Type | Description |
websiteId | Integer | (Mandatory) The ID of the website to get checkpoint details. |
checkpointId | Integer | (Mandatory) The ID of the checkpoint to get graph data. |
graphName | String | (Mandatory) The name of the graph to get data where possible values are status , performance (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)
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 srvId
, checkId
, period
, datapoints
, and aggregate
which are specific to GET /website/websites/{srvId}/checkpoints/{checkId}/data
are described in the following table.
Parameter | Type | Description |
srvId | Integer | (Mandatory) The ID of the website. |
checkId | Integer | (Mandatory) The ID of the service checkpoint to get data. |
period | Number | The number of hours for which data must be returned. |
datapoints | String | The datapoints associated with the website for which data is returned. |
aggregate | String | Available values are – first , last , min , max , sum , average , 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)
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.
Parameter | Type | Description |
id | Integer | (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)