Skip to content

Instantly share code, notes, and snippets.

@dhbradshaw
Created February 10, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhbradshaw/cf7db8d6365c58e9234ae86c10f41cd7 to your computer and use it in GitHub Desktop.
Save dhbradshaw/cf7db8d6365c58e9234ae86c10f41cd7 to your computer and use it in GitHub Desktop.
PagerDuty Resolver Bot

Resolving my pagerduty problems with a simple js script

No user deletions for you!

Recently I had to delete a user from pagerduty, but the interface blocked me from doing so, saying that I couldn't complete the deletion until all of that users issues were resolved.

Slog ahead

I looked at the unresolved issues and there were thousands.
These issues were beyond their expiration dates, and could be marked resolved, but the process of doing so was time consuming.
Each round of deletion took at around 10 seconds because of latency and each involved 3 separate clicks. Further, each round of deletion only eliminated at most 100 incidents.

Resolver bot

But the glory of coding is that repetitive boring tasks become opportunites to try something fun to automate them.

Anyway, here's the script that I put together to mark these expired issues as resolved while I worked on other things:

setInterval(() => {
    document.getElementsByClassName("ember-checkbox")[0].click(); 
    document.getElementsByClassName("resolve-incidents")[0].click(); 
    document.getElementsByClassName("btn-primary")[0].click();
}, 10000)

It just performs the three required clicks and then waits while the next set of resolved issues is loaded before it starts again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment