How to add filters to API call for SDT devices
Hello -
I am able to fetch SDT devices by calling REST API https://abc.logicmonitor.com/santaba/rest/sdt/sdts?filter=type:DeviceSDT
How do I add additional filters based on system property ( Operating system) and Custom property (Region). Not able to filter results using below.
Sammy
3 comments
LM User
Swagger documentation shows that those attributes aren't contained in the response:
So, you'll have to make a call to /device/devices either for each item in the response, or fetch all the devices and marry the two lists together within your script.
FYI, using the SDK, this is pretty simple:
This prints out each device SDT with the corresponding device record. You could use dictionary comprehension to build a quick dictionary with this stuff all zipped together.
Sammy
OPThank you for the detailed explanation.
I tried to fetch the required values in response so I can filter based on that. But only the first 3 fields are appearing in result. Is there a way to get the required system & custom properties in response?
{{url}}/sdt/sdts?filter=type:DeviceSDT&fields=deviceDisplayName,admin,timezone,system.collectorplatform,customProperties
LM User
Filtering on properties is tricky. You can filter by the name of the property and by the value of the property, but the name and value in these cases don't have to belong to the same property.
Example properties:
Device A: firstName: Santa, lastName: Claus, enemy: Frost
Device B: firstName: Jack, lastName: Frost, enemy: Claus
A filter of customProperties.name:firstName,customProperties.value:Claus would return both device A and device B because device A has a property called "firstName". It also has a property with a value of "Claus". The problem is that device B also has a property called "firstName" and it also has a property with a value of "Claus".
I normally only use simple filters in the API call. I do the more complex filtering after fetching the data.