Alert/Alerts API endpoint
Hello Everyone,
I am trying to get the list of all alerts through the API. Endpoint I am using is https://companyname.logicmonitor.com/santaba/rest/alert/alerts?v=3
Through this API I am only able to get the Uncleared Alerts.
Now, Issue is I want all alerts including the one that has been cleared for reporting purpose.
I would really appreciate if anyone could help me with this?
Thank you,
Mnaish
Mpyakurel
Posted 1 year ago·Last reply 1 year ago
4 comments
Mike Moniz
·1 year agoOne issue with the new Swagger documentation is that LM doesn't appear to put any real notes in there. When using the API I suggest also looking at the old API v1 documentation as it does show various notes and comments on how parameters work and gotchas like this. For example on https://www.logicmonitor.com/support/rest-api-developers-guide/v1/alerts/get-alerts it mentions the Clear:* use and also how negative totals work.
Joe Williams
·1 year agoWe do the same actually. We have expressed to our CSM that the programmatic approach to generating the swagger lost us the ability to easily consume the methods and the best way to approach the stuff. Honestly this is why I ended up writing my own "sdk" in python.
But it does appear they are making strides. I have seen a lot more articles show up in the newer section, they just aren't as detailed as the older ones.
Joe Williams
·1 year agoBy default the API only returns active alerts. To return alerts in any state you need to send a filter of cleared with an star.
Just remember tho, if you truly want "every" alert. You can't paginate more then 10 times, so your limit is 10000. You will need to break it up in smaller chunks of time. An example of that would be something like below in python. This gets epochs for every hour of every day for the past X days. Then loops through and gets the alerts for that hour. If your portal is anything like ours, you will still hit that 10000 limit occasionally but it works pretty well.
Mpyakurel
OP1 year agoThanks Joe. Much Appreciate.