Forum Discussion

AdamB's avatar
3 years ago

Problem with fetching instances from device

Hi I'm quite new with LogicMonitor so sorry for maybe obvious question - I'm trying to get list of instances for specific datasource from specific device via python script It should be fai...
  • Anonymous's avatar
    Anonymous
    3 years ago

    I recommend using the SDK. Also, instead of x['dataSourceId'], try x['id']. The dataSourceId is the global ID for the datasource. The instances are not tied to that. They are tied to the "hdsId", which is the ID of the datasource as it's applied to that device and it's unique for that one device. 

    Because of this unique ID on the device, it's actually quite tedious to get all the instances for a particular datasource across multiple devices. You have to make one call for the hdsId, then another call to get the instances. Another option would be to just make a call to /device/devices/{id}/instances and fetch all the instances on the device. That response contains both the hdsId and the dataSourceId, so if you know the global ID of the datasource(s), you can then filter in script.