cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete expired maintenance window via API

AK
Pro

Hi Folks,

Is there a way to delete all expired maintenance window via API.

I gone through few thread on community and suggestion was to filter on expired maintenance window and delete from UI itself.

But dilemma is, due to huge number of maintenance window the page is not at all loading hence I'm looking to pull all expired MW via API and delete it.

Can someone please suggest.

Regards,

AK

2 REPLIES 2

victor_balbuena
Dynatrace Mentor
Dynatrace Mentor

You can use the Dynatrace API to automate the process, but you will need to build the logic into whatever script or job you decide to run to delete them.

So the steps would be:

  1. Get all maintenance windows with the Settings API v2 using the builtin:alerting.maintenance-window schema ID.
  2. With the list of IDs, get every maintenace window via the same Settings API v2, different endpoint .
  3. For each maintenance window, dive into the body response of the call and check if the scheduleType is ONCE and if the endTime is in the past (we ignore recurring maintenance windows since they are never expired).
  4. If the above verifies, save the ID of the object and make one last call to the Settings API v2, delete an object to delete it.

It's a bit complicated, but it's the only way as the maintenace window doesn't have an expired field or something else we can check apart from the one mentioned above.

Yep this works. @victor_balbuena thanks for quick help

Featured Posts