how can we close all the alerts from opsgenie console in one go, like now i am allowed to only close 1000 alerts at a time. 100000 alerts have been piled up and its diffcult to delete in batch
Hello @devops
Thank you for reaching out! A similar question was posted here in 2019 was answered in 2022. The suggestion was to write a custom script leveraging the Alert API or you can use the Opsgenie lamp in your scripting although in either case you would need to take pagination into account. The idea is to create a script to list the alerts via API, then loop through each one and delete it via API. Someone graciously shared a link to an "opsgenie_cleaner" python script they wrote.
One way test or to limit the scope of the deletion is to use an apiKey from a team-based API integration so that you would only be able to delete the alert belonging to that team. Once tested to your satisfaction, then use an apiKey from a global API integration, that is one, not assigned to any team to be able to act on all alerts.
Since you have more than the hard limit of 20,000 alerts, another community post suggests that you would want to break your searches into smaller batches with something like the createdAt criteria.
Yet another related and informative community post from 2022 is this one.
As for me personally, not fluent in scripting or prompt engineering, my preference would be to use the Web UI, although as you pointed out you can only Close (or Ack) (up to) 1000 alerts at one time using "bulk actions on alerts" and even then, each batch of 1000 alerts takes quite a few minutes to complete before you can execute the bulk action on the next batch of 1000.
On the plus side, it only takes a few seconds to kick off the bulk action and you can do something else in that 20 or so minutes before kicking off the next batch of 1000 alerts. So for 100000 alerts, it would take a hundred batches that you would literally run over the course of a few days (although with a script, the run time may be cut to a third but it would take time to write your custom script and test it).
I hope the above points you in the right direction.
Best Regards,
~Wei
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.