Querying alerts via API
Hi
I'm fairly new to APIs and would like a little help please. I am trying to query the LM API for specific alerts with Python. I am able to retrieve a full list of alerts via Python which is a good starting point. I was using the following doc:
https://www.logicmonitor.com/support/rest-api-developers-guide/v1/alerts/get-alerts
What I would like some help with is the following:
- Is there a way to retrieve alerts only for a specific folder? We have customers under specific folders.
- How would I retrieve alerts with only a specific string in the resource name? E.g. all customer devices will have devicename.domain.com I would like to filter for only alerts of devices with *domain.com* in the resource name.
- How would you do multiple queries in one API call? e.g. a query with a filter, and a sort?
Thank you
- Anonymous5 years ago48 minutes ago, MrJ said:
For the v2 API, does it display the data any different or is the only difference no support for basic auth?
The data structure changes for v2 and some of the endpoints are different. Some more info here. The v2 REST documentation is here: https://www.logicmonitor.com/swagger-ui-master/dist/#/Alerts/getAlertList, but the filtering shouldn't be any different.
As far as why it's not working (meaning you're getting an http 200 but not filtered results), I am wondering if the filter can only affect those fields included in the response. That being the case, can you filter based on the value of `monitorObjectGroups`? Unfortunately, being end of quarter, I don't have the time to run any tests to figure out what works.