Incidents acknowledged by users in a timeframe

rest-api

(Jay Sangra) #1

We are trying to post a widget on our TVs which show the top 3 users who acknowledged the most Incidents in a week. Not sure if the best way to achieve this would be via the incidents or log enteries api. Any suggestions?


(Joe Pettit) #2

Hey Jaskaran,

Thanks for reaching out - interesting project there.

I think your best bet here would the log entries endpoints, specifically: https://v2.developer.pagerduty.com/page/api-reference#!/Log_Entries/get_log_entries

This will allow you to input since and until so you could easily input a date in since for Monday at 00:01 and until to Sunday at 23:59 to grab the entire week. From there you can iterate through the log entires and count up the number of acks for each user ID.

With that information you can use the get users endpoint to show more human readable information like the user’s email: https://v2.developer.pagerduty.com/page/api-reference#!/Users/get_users_id

I hope that helps! Don’t hesitate to let us know if you have any other questions.


(Jay Sangra) #3

Thanks Joe. I had 2 followup questions for log enteries:

  1. What types are returned by “is_overview=true”. The documentation says only important changes, what classifies as an important change?
  2. Is there a way to filter on types on the api itself? e.g. “type”: “acknowledge_log_entry” so i dont have to iterate thru pages of data. I think it would be cumbersome if we have 10K log enteries in a period of 1 week.

(Joe Pettit) #4

Hey Jaskaran,

Sure thing:

  1. What types are returned by “is_overview=true”. The documentation says only important changes, what classifies as an important change?

This is essentially limited to major lifecycle changes like triggers, acks, resolves and so forth. Setting is_overview to true will remove some of the noise like notes and less important non-lifecycle related actions. You can view the differences by throwing an API key in the link I provided in my previous update before clicking “Try It”. Much easier than playing around with CURL for simple tests.

  1. Is there a way to filter on types on the api itself? e.g. “type”: “acknowledge_log_entry” so i dont have to iterate thru pages of data. I think it would be cumbersome if we have 10K log enteries in a period of 1 week.

There is not presently a way to filter based on log type, unfortunately. If you have a lot of activity on your account each week, this could be a bit cumbersome. An alternative approach would be to use webhooks to listen for incident changes. This would require another piece of infrastructure but it would reduce the noise.

Just let me know if you have any other questions!