Forum Discussion

Lewis_Beard's avatar
3 years ago

Search in LogicMonitor for information in the Instance Description (system.instanceDescription)


I am pretty green when it comes to LogicMonitor. I inherited a LM system when our LM admin left the company.

So I discovered that the engineers who have been using the system have put some important information, I would like to be able to search for, in the instance description (not the name).

It seems that the standard search doesnt support search results in the instance description, so I am wondering if there is any workaround?

I tried making a csv report with all resources and the VLAN Interfaces (64 bit) and that would have worked, except the canned selection of that only includes the name, not the description. I dont seem to have control over that.

So I am wondering if there is any way to do this. I suppose I could look at the API, but I'm not sure if that would be practical.

Before I dig in that direction, I was hoping someone might know of a way to do this in the UI that I've missed.




4 Replies

  • Anonymous's avatar

    The only thing that is coming to mind is to switch the mapping between the discovered data so that the description becomes the instance display name instead of the name becoming the instance display name. That could prove problematic for a couple of reasons (the widespread use of that datasource and therefore impact of any change being one, the difficulty in keeping that module up to date another). You would make this change in the active discovery section of the definition of that datsource. If you want to go that route, let's discuss.

    If you do end up doing API...seriously: sdk.

  • Can I ask a dumb followup rather than making a new post?

    I installed python and the sdk and I managed to search and find what I'm looking for, so I have a programmatic path forward.

    However, while I can search and get back from the API (via SDK) matching what I was searching for, by making a filter specifying what I want ....

    ... I cannot for the life of me figure out what is going on when I try to specify that I just want certain fields.

    So my real question is this: Is this forum the place to ask about 3rd party API problems?

    And my other question, since it is related to the link you sent, I went to the page with examples for the API, thats how I got my code working, but all the examples say stuff like this:

       fields = fields_example # String | (optional)

    Where do I find what fields_example is? Or any of the others? I feel like there is a page I am supposed to have seen. But I cant seem to find it.

    My code is this: api_response = api_instance.get_device_list(fields=fields, filter=filter)

    And when fields is "" then I get my device response back, but as soon as I just set fields to something like "name" then I get some error about display_name cant be None, and if I havent been able to find anything definitive in my searching.

    But my google-fu is weak.

    Any chance you can point to where actual fields examples live?



  • Anonymous's avatar

    Don't know what you mean about "3rd party API problems" because the SDK is supported by LogicMonitor AFAIK and you're accessing LM's API. 

    The SDK documentation is built by Swagger which is the software LM uses to build the API in the first place. So, where the SDK documentation is lacking, think about this: the SDK is just a sexier skin on top of the API. So, for questions like "what values can i put in for fields?", you'd look in the API documentation here, here, and here.

    That said, what you're looking for is to limit which fields are returned. For that, you simply supply a comma separated list of the fields you want back. There are two tricks to get it to work:

    One is that you have to specify the fields as the API calls them, not as the SDK calls them. So, where the SDK outputs "display_name" for the display name, the API actually calls that field "displaName". And where the SDK calls it "preferred_collector_id", the API calls it "preferredCollectorId". 

    The other is that there are certain fields you always have to return. Those are "displayName,preferredCollectorId,name". So, if you want the id, the display name, the host_group_ids, and the created on fields, you'd need to specify it like this:

    lm.get_device_by_id(id=9, fields="displayName,preferredCollectorId,name,hostGroupIds,createdOn")

    However, when you make that call, you will notice that something like this will come back:

    {'auto_balanced_collector_group_id': None,
     'auto_properties': None,
     'auto_props_assigned_on': None,
     'auto_props_updated_on': None,
     'aws_state': None,
     'azure_state': None,
     'collector_description': None,
     'created_on': 1561139692,
     'current_collector_id': None,
     'custom_properties': None,
     'deleted_time_in_ms': None,
     'description': None,
     'device_type': None,
     'disable_alerting': None,
     'display_name': 'Smart Panel 8x1G switch',
     'enable_netflow': None,
     'gcp_state': None,
     'host_group_ids': '258,3',
     'host_status': None,
     'id': None,
     'inherited_properties': None,
     'last_data_time': None,
     'last_rawdata_time': None,
     'link': None,
     'name': '',
     'netflow_collector_description': None,
     'netflow_collector_group_id': None,
     'netflow_collector_group_name': None,
     'netflow_collector_id': None,
     'preferred_collector_group_id': None,
     'preferred_collector_group_name': None,
     'preferred_collector_id': 106,
     'related_device_id': None,
     'scan_config_id': None,
     'system_properties': None,
     'to_delete_time_in_ms': None,
     'up_time_in_seconds': None,
     'updated_on': None,
     'user_permission': None}

    So, there's some major bugginess with regard to how the SDK handles "fields". The answer is to not try to filter in the call, but do filtering within your own script, which isn't too hard once you convert the returned data to a dictionary:

    mydevice = lm.get_device_by_id(id=9).to_dict()
    selected_fields = ['id','display_name','host_group_ids','created_on']
    mydevice_with_selected_fields = {key: value for key, value in mydevice.items() if key in selected_fields}
    for k,v in mydevice_with_selected_fields.items(): print(f"{k}: {v}")

    Which lets you reference the fields as the SDK calls them and outputs something like this:

    display_name: Smart Panel 8x1G switch
    created_on: 1561139692
    id: 9
    host_group_ids: 258,3