Forum Discussion

shaunatblinker's avatar
8 years ago

Add hostName filter parameter to REST API

Currently there is no hostName parameter available for the REST API though it exists in the RPC API.  When retrieving information about a device using the 'devices/device' endpoint using the REST API:

/devices/device/?filter=deviceType:0,name~<some ipv4 address>,size:1

There is a chance that the device being returned is actually another device when using the ~ operator against the name of the device.  There would be quite a bit of work to wildcard filter by name and would be different depending on the tenant's naming schema. Adding the hostName parameter as a feature would mirror RPC's functionality and save quite a bit of custom code from being written.

If anyone is aware of how to filter by hostName or similar (ipv4) parameter without additional operations please let me know.

  • Sarah_Terry's avatar
    Sarah_Terry
    Icon for Product Manager rankProduct Manager

    Hi Shaun,

    LogicMonitor's REST API devices resource includes the name (hostName, IP/DNS), displayName & id.  Though the REST API operates based on resource ids, you can still filter your request by displayName, name, or any other parameter - so you should be able to get the same information as the RPC API (and actually the REST API provides more powerful filtering than the RPC API).  

    You are correct that filtering by name as you've done may return more than one result - you can avoid that by (1) filtering by displayName instead, as that is guaranteed to be unique (e.g. ?filter=displayName:prodServer123) or (2) adding preferredCollectorId to the filter, as the name/IP is guaranteed to be unique for a given Collector (e.g. filter=name~8.8.8.8,preferredCollectorId:9). 

    Does that answer your question?  If not, can you provide the RPC request you're making that you're trying to replace with REST?  That will help with context.

    Thanks,

    Sarah