LogicMonitor seeks to disrupt AI landscape with $800M strategic investment at $2.4B valuation to revolutionize data centers.

Learn More

Getting Datasource Instance Details

Last updated on 07 October, 2024

You 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.

ParameterTypeDescription
fieldsStringThe 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
sizeIntegerIndicates 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
offsetIntegerIndicates the number of results to offset the displayed results.
Example – /device/devices/34/devicedatasources/90/groups?offset=2
filterStringThe response is filtered according to the operator and specified value that is, filter=property:value
  • Use an asterisk (*) to match more than one character
  • Use a dot (.) character to filter values within an object (example – custom properties)
  • Use a comma (,) to separate multiple filters

Operators include:
  • Greater than or equals >:
  • Less than or equals <:
  • Greater than >
  • Less than <
  • Equals :
  • Does not equal !:
  • Includes ~
  • Does not include !~
Example – /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: fieldssizeoffset, 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 deviceIdhdsId, and instanceId that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config are described in the following table.

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
instanceIdInteger(Mandatory) The instance ID.

Getting Device Datasource Instance Group List

URI: GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups

The query parameters: fieldssizeoffset, 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.

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
deviceDsIdInteger(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: fieldssizeoffset, 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.

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(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)
Python 3

Getting Device Instance SDT History

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

The query parameters: fieldssizeoffset, 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 deviceIdhdsId, and id that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts are described in the following table.

ParameterTypeDescription
deviceIdInteger(Mandatory)The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
idInteger(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 deviceIdhdsId, and id that are specific to /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id} are described in the following table.

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
idInteger(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)
Python 3
In This Article