Getting Datasource Instance Details
Last updated on 07 October, 2024You can use LogicMonitor REST API v3 to get datasource instance details. You must authenticate yourself before making the API request.
Common Query Parameters
The following query parameters are common to all the GET calls for datasource instances.
Parameter | Type | Description |
fields | String | The response is filtered to include only the specified fields for each object. You can provide a list of properties separated by a comma. Example – /device/devices/9/devicedatasources/24/groups?fields=name,id |
size | Integer | Indicates the number of results to display. A maximum of 1000 results can be requested in a GET call. By default, a list of 50 device datasources is returned if a value is not provided for this parameter. Example – /device/devices/87/devicedatasources/54/groups?size=5 |
offset | Integer | Indicates the number of results to offset the displayed results. Example – /device/devices/34/devicedatasources/90/groups?offset=2 |
filter | String | The response is filtered according to the operator and specified value that is, filter=property:value
Operators include:
/device/devices/43/devicedatasources/76/groups?filter=name:"prod*" |
Getting Detailed Instance Configuration Information
URI: GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config
The query parameters: fields
, size
, offset
, and filter
should also be included while making the call GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config
. For details, see the common query parameters table.
Additional parameters deviceId
, hdsId
, and instanceId
that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config
are described in the following table.
Parameter | Type | Description |
deviceId | Integer | (Mandatory) The device ID. |
hdsId | Integer | (Mandatory) The device datasource ID. |
instanceId | Integer | (Mandatory) The instance ID. |
Getting Device Datasource Instance Group List
URI: GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups
The query parameters: fields
, size
, offset
, and filter
should also be included while making the call GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups
. For details, see the common query parameters table.
Additional parameters deviceId
and deviceDsId
that are specific to /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups
are described in the following table.
Parameter | Type | Description |
deviceId | Integer | (Mandatory) The device ID. |
deviceDsId | Integer | (Mandatory) The device datasource ID that you want to get instance groups list. |
Getting Device Instance List
URI: GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances
The query parameters: fields
, size
, offset
, and filter
should also be included while making the call GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances
. For details, see the common query parameters table.
Additional parameters deviceId
and hdsId
that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances
are described in the following table.
Parameter | Type | Description |
deviceId | Integer | (Mandatory) The device ID. |
hdsId | Integer | (Mandatory) The device datasource ID. |
Run the following Python script to get all instances for device ID 533 and device datasource ID 10256.
#!/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/10256/instances'
queryParams = ''
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 SDT History
URI: GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts
The query parameters: fields
, size
, offset
, and filter
should also be included while making the call GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts
. For details, see the common query parameters table.
Additional parameters deviceId
, hdsId
, and id
that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts
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 needed to get SDT history. |
Getting Device Instance
URI: GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}
The query parameter fields
should also be included while making the call GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}
. For details, see the common query parameters table.
Additional parameters deviceId
, hdsId
, and id
that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}
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 needed to get device instance. |
Run the following Python script to get all instances for device ID 533, device datasource ID 10256, 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/10256/instances/23'
queryParams = ''
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)