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

Learn More

Adding Datasource Instances

Last updated on 07 October, 2024

You can add datasource instances that do not have Active Discovery enabled. You must authenticate yourself before making the API request.

URI: POST /device/devices/{deviceId}/devicedatasources/{hdsId}/instances

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
isUNCInstanceBooleanIndicates if UNC monitoring is enabled for the device.
stopMonitoringBooleanIndicates if monitoring is disabled for the instance.
displayNameString(Mandatory) It is the instance alias. It is the descriptive name of the instance and should be unique to the device/datasource combination.
wildValue2StringOnly used for two dimensional active discovery. When used, during active discovery runs, the token ##WILDVALUE## is replaced with the value of ALIAS and the token ##WILDVALUE2## is replaced with the value of the second part alias. This value must be unique to the device/datasource/WILDVALUE combination.
groupIdIntegerThe instance group ID associated with the datasource instance.
descriptionStringThe description of the datasource instance.
disableAlertingBooleanIndicates if alerting is disabled for the instance.
systemPropertiesJSON Array Specify the name and value of instance level system properties assigned to the instance.
autoPropertiesJSON ArraySpecify the name and value of instance level auto properties assigned to the instance.
customPropertiesJSON ArraySpecify the name and value of instance level custom properties assigned to the instance.
lockDescriptionBooleanIndicates if Active Discovery is enabled, and if the instance description is editable.
wildValueString(Mandatory) The variable part of the instance, used to query data from a device. For example, variable part of the SNMP OID tree. This value must be unique for the device/datasource combination, unless two-dimensional active discovery is used.

The following Python script adds an instance ‘google’ to the HTTP_Page datasource for device ID 38 in api.logicmonitor.com account.

#!/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 ='POST'
resourcePath = '/device/devices/38/devicedatasources/2214/instances'
data = '{"wildValue":"www.google.com","displayName":"google"}'
 
#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 + data + resourcePath
 
print requestVars
 
#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.post(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Adding Configuration Collection to Device

You can use LogicMonitor REST API v3 to add configuration collection to devices.

URI: POST /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config/configCollection

ParameterTypeDescription
deviceIdInteger(Mandatory) The device ID.
hdsIdInteger(Mandatory) The device datasource ID.
instanceIdInteger(Mandatory) The instance ID to add configuration collection.
In This Article