REST API Developer's Guide

Get Config Data

You can use LogicMonitor's REST API to programmatically get monitored configuration files for your LMConfig devices.  

As with all of our API calls, authentication is required.

 

Get all configs for a ConfigSource instance

HTTP Method: GET

URI:  

/device/devices/<deviceId>/devicedatasources/<deviceDataSourceId>/instances/<instanceId>/config

Where:

  • deviceId is the device id, which can be obtained via the Devices Resource
  • deviceDatasourceId is the id of the ConfigSource, which can be obtained via the Device Datasource Resource
  • instanceId is the id of the ConfigSource instance for which you want to retrieve a config, which you can get from the Instance resource

Request Parameters:By default, a list of 50 stored config results will be returned. You can include the following query parameters that control what data is included in the response and how it is formatted. Note that query parameters are not considered part of the resource path, and should not be included the calculation of the LMv1 authentication signature.

Property

Syntax

Description

Example URI

fieldsfields=list of properties separated by commas Filters the response to only include the following fields for each object /device/devices/12/devicedatasources/45/instances/67/config?fields=id,version,deltaConfig
sort sort={+ or -}property Sorts the response by the property specified in either increasing (+) or decreasing (-) order /device/devices/9/devicedatasources/65/instances/84/config?sort=-version
filter filter=property{operator}value Filters the response according to the operator and value specified. Note that you can use * to match on more than one character.You can use the '.' character to filter values within an object (e.g. custom properties), and multiple filters can be separated by a comma.

Operators include:
  • Greater than or equals: >:
  • Less than or equals: <:
  • Greater than: >
  • Less than: <
  • Does not equal: !:
  • Equals: :
  • Includes: ~
  • Does not include: !~
/device/devices/3/devicedatasources/65/instances/84/config?filter=changeStatus:Change
size size=integer The number of results to display. Max is 1000. /device/devices/5/devicedatasources/65/instances/84/config?size=5
offset offset=integer The number of results to offset the displayed results by /device/devices/6/devicedatasources/65/instances/84/config?offset=2



Each config will include an id, version, timestamp, the configuration file text, the differences detected from the last version, and any alerts that were triggered based on the changes. To get only the latest version of a config, you can sort by version and limit the results to one by using the following query parameters: ?sort=-version&size=1

 

Example 1

The following Python script will return config data for device 674, ConfigSource 14921, instance 210728286:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='GET'
resourcePath = '/device/devices/674/devicedatasources/14921/instances/210728286/config'
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
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#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