Statistics and Counts in v2


(Jay Sangra) #1

We are working on moving from v1 to v2 api’s and were running into some issues with certain APIs. We are relying heavily on these 2 apis from v1 on our monitoring dashboards:

  1. GET alerts_per_time : We migrated this by using /notifications but it seems we have to filter and count on results to get phone, sms, email and push notifications. This process seems cumbersome vs the old API.

  2. GET incidents/count : This one was used to query count of triggered/acknowledged incidents by service as well as the total counts for all services. With v2 it seems there is no equivalent of count and we have to get detailed incidents and filter to get the desired results. Are there any plans to include counts?

Also do you guys plan on creating any statistical APIs for getting mean time to Ack/Resolve incidents by services/users/team?

(Monica Hom) #2

Hey Jay! Thanks for the feedback! When using the v2 AP vs the v1 API, you obtain more information regarding the notification from users filtering and listing the notifications as they are used. At the moment for the List notifications endpoint, this cannot be changed or modified. However, I would love to inform our product team here at PagerDuty as well to see what other options we have when making this call to avoid filters and counts.

For the List incidents v2 API, what you can do to obtain the count is append ?total=true at the end of the request URL and then you will be able to obtain the total count of incidents from the response JSON. Lastly, at the moment we are aware of some request for statistical API but at the moment we, unfortunately, do not have any. I will add your request as a feature request so our product team is aware of this! However, if you like to obtain a portion of that information, you can use our List log entries endpoint.

Please let me know if you have any further questions and I would more than happy to help out.

(Jay Sangra) #3

Thanks Monica. Your response was very helpful. I am responding a bit late as i wanted to try these all out. From my testing the fastest response comes when i do ?total=true&limit=1 in cases where i am only interested in getting counts and not the full data back. We look forward to more statistical APIs in future.

(Jay Paige) #5

Hey Jay! No problem on the wait at all! We are glad to hear you have tested this out on your end. Please let us know if you have any other questions or would like to add anything to your initial request.

(Joe) #6

Hi Jay,

I tried your method to get back the count for incidents but I still get back full data. Could you please point out what I’m missing from the path below?


(Jay Sangra) #7

@battousai_ln With limit=1 you should only see full data for only 1 incident v.s. bringing back the default 25 which is faster/lighter call. Also the total=true gives the total count of the incidents based on your statuses filter i.e. triggered, acknowledged, resolved. I have not tried limit=0. Maybe it works but i didn’t attempt it as it was not there in the API reference.

Here is a sample get request to get triggered incidents for a service:


(Jay Sangra) #8

@battousai_ln Just confirmed limit cannot be 0. I get this error:
“error”: {
“message”: “Invalid Parameters”,
“errors”: {
“limit”: [
“must be greater than or equal to 1”

If you dont want to filter by service and want a global triggered/acknowledged count you would make a get request against these urls.

(Joe) #9

thank you Jay!

(system) #10