Background: I’m writing examples against the PagerDuty API for our developer evangelism team, here’s a sneak preview:
A dashboard of recent incidents
Some of our users have been using browser plugins to refresh the dashboard more frequently, there are some great tools that work with PagerDuty to do that: StatusPage.io, Geckoboard, along with open source projects like pagerduty-dashing and Brainiac.
But I reached out to some of those accounts, and they wanted something that:
- Can be displayed on a monitor like a status board
- Gives at-a-glance awareness of the volume and distribution of incidents to non-responders
Let’s do that with our API directly. Here are the most recent incidents grouped by when they happened including the state and who’s currently assigned.
Or, if you want to get started right away, it’s also easily configurable from the URL by passing in your subdomain and an
API key. Put in your own values to generate your status page:
How does it work:
See the source code
If you view the source, you’ll see it’s just one function “loadIncidents” which is run once the page loads and hits the incidents API then loops through them for display, and finally schedules itself to run again in 30 seconds (Not the most efficient solution but it’s the easiest to explain). Here’s the important part in a little more detail:
There are some other ingredients to this example:
- I wrote some CSS quickly, please feel free to take this code and make it much prettier — let us know what you build:
- There is also some code to parse query and hash parameters so that anyone could use this example. I’m a little proud of that last bit since anything after the #
is not sent to the server
- Moment.js is being used to format and manipulate times.
Bonus question: List everyone in an account by escalation policy
I’ve also been asked to list all user by which escalation policy they’re on. It’s not as visually appealing as the status page, but a pretty easy snippet nonetheless: