Summary of project's issue/events count

We built a dashboard based on the sentry (community edition, v8.22) REST API for some of our sentry projects showing the following numbers as a time series:

  • total number of unresolved issues in the project
  • total number of resolved issues in the project
  • total number of events of unresolved issues in the project
  • total number of events of resolved issues in the project

Currently we’re facing the problem that a project with a large amount of issues causes a lot of API Calls to /api/0/projects/org_slug/project_slug/issues/?cursor=... due to the pagination just to get the total number of issues in a project. (2000 issues => 20 GET requests that deliver all issue information)

Currently I only see an endpoint to get all event counts of a project (/api/0/projects/org_slug/project_slug/stats/), but not an issue count.
It would be great to have a similar endpoint for issue counts of a project or to simply include the number of issues in the /stats/ endpoint.

Please correct me, if I miss something?

Do you have a link to the GitHub project of the dashboard code / configuration? :wink:

Unfortunately not, it’s an internal project. But what we do is:

  1. We call the API endpoint /api/0/projects/org_slug/project_slug/issues/?query=...&cursor=... for the particular project until the next Link header says results="false"
  2. On each retrieved page we sum the count of the root array returned to get the total number of issues
  3. On each retrieved page we sum the event “count” of each issue to get the total number of events
  4. We produce the following output for prometheus which scrapes this data:
sentry_issues{organization="***", project="proj1", status="resolved", type="total"} 4461.0000
sentry_issues{organization="***", project="proj1", status="resolved", type="aggregated"} 14.0000
sentry_issues{organization="***", project="proj1", status="unresolved", type="total"} 154209.0000
sentry_issues{organization="***", project="proj1", status="unresolved", type="aggregated"} 10.0000
sentry_issues{organization="***", project="proj2", status="resolved", type="total"} 26852.0000
sentry_issues{organization="***", project="proj2", status="resolved", type="aggregated"} 52.0000
sentry_issues{organization="***", project="proj2", status="unresolved", type="total"} 297230.0000
sentry_issues{organization="***", project="proj2", status="unresolved", type="aggregated"} 280.0000
sentry_issues{organization="***", project="proj3", status="resolved", type="total"} 1402.0000
sentry_issues{organization="***", project="proj3", status="resolved", type="aggregated"} 76.0000
sentry_issues{organization="***", project="proj3", status="unresolved", type="total"} 946643.0000
sentry_issues{organization="***", project="proj3", status="unresolved", type="aggregated"} 2296.0000

… where “aggregated” means total count of issues and “total” means total count of events.
These numbers are scraped by prometheus in interval X to create a time series.

Prometheus then is the datasource for a grafana instance visualising these time series as graphs.

All that works fine, except the fact that creating these simple numbers takes a lot of time because we need to make so many calls to the Sentry API.

In a perfect world it should be one API call per project that gives me issueCount = x and eventCount = y.