Getting a list of unresolved incidents in the last 7 days

rest-api
(Shobhit Gupta) #1

Hi,

I am trying to calculate downtime in the last x days.

For this I am trying to use the PD incidents API to get a list of incidents that are either:

  1. currently unresolved.
    or
  2. were resolved in the last 7 days.

I tried using the since param in the incidents api. But it seems the purpose of since is based on created date.
In other words, if I had 10 incidents, and all of them were opened 1 year ago but are currently open or only resolved in last 7 days. Those incidents will not show up if the since is set to 7 days ago. There is no way to query those incidents.
I guess what I need is a an equivalent of an api param called unresolvedSince which would include all those incidents that were in an unresolveed state even for 1 or 2 hours after unresolvedSince timestamp.

Right now the only way is that I query API with since set to something ridiculously large and then filter the results later based on resolved date. I am sure there has to be a better way to do this.

Please help with how can I query for the information that I need.

regards,
Shobhit

(Thomas Roach) #2

You should be able to use the triggered and acknowledged statuses to achieve this. Could you please send us the call you’re making so we can look further into this?

(Shobhit Gupta) #3

API: https://api.pagerduty.com/incidents?since=2019-04-11T22:22:35.039Z&service_ids[]=P9FD11K&time_zone=UTC

Inspect the response:

> response.incidents.map(i => {return {created_at: i.created_at, status: i.status, last_status_change_at: i.last_status_change_at}})

[
  {
    "title": "testing incident [all_verticals]",
    "created_at": "2019-04-11T22:22:36Z",
    "status": "resolved",
    "last_status_change_at": "2019-04-11T22:28:30Z"
  },
  {
    "title": "[all_verticals] shobhit-testing",
    "created_at": "2019-04-11T22:30:17Z",
    "status": "acknowledged",
    "last_status_change_at": "2019-04-11T22:30:23Z"
  }
]

Lets focus on testing incident [all_verticals] incicent.

Currently the since in query is 2019-04-11T22:22:35.039Z. If I increase this to be slightly more than the created_at of testing incident [all_verticals], then I can’t query it.

API: https://api.pagerduty.com/incidents?since=2019-04-11T22:22:37.039Z&service_ids[]=P9FD11K&time_zone=UTC

Inspect the response:

> response.incidents.map(i => {return {created_at: i.created_at, status: i.status, last_status_change_at: i.last_status_change_at}})

[
  {
    "title": "[all_verticals] shobhit-testing",
    "created_at": "2019-04-11T22:30:17Z",
    "status": "acknowledged",
    "last_status_change_at": "2019-04-11T22:30:23Z"
  }
]

I would like to be able to query all the issues that:

  1. were open before since timestamp but were not marked resolved at the timestamp of since (current status doesn’t matter).
    +
  2. were opened after since timestamp.

I am missing the first point.

Thanks,
Shobhit

(Thomas Roach) #4

You could use an Incident Report to determine this data since it does report on both the number of incidents and the data field Duration.

I have provided a link to this analytic tool’s landing page in your account here. You can navigate to this page yourself by going to Analytics -> Incident Volume.

Please refer to the below Knowledge Base article on this particular tool here as a useful resource:

Incidents Report

Unfortunately, outside of this and some manual work on your part, we can’t facilitate for this at this time. I’d be happy to submit a feature request on your behalf to our Product team though!

(system) closed #5

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.