Api/measures/search_history and api/issues/search don't match for a time period

I’m using version of the SonarQube Community edition and I’m trying to use the APIs to produce some reports against a specific project.

I’m using api/measures/search_history with the from (start time), to (end time) and component parameters.

This pulls me back a decent set of data that looks like this (and there is some other data as well):

So i’m trying to pull back the matching information of the actual issues that were opened and closed in this time (and therefore who hasn’t closed issues raised) using the API api/issues/search with the createdAfter (start time), createdBefore (end time) and componentKeys parameters. I assumed this would pull be back the same numbers off issues but it doesn’t.

Instead it pulls me back the following (which is matched from the SQ console):


Why is there a difference and how do I map up the stats between two time periods and the details of who created an issue and didn’t resolve it?


It’s not clear to me from the body of your post what you’re comparing to see a mis-match. From the post subject I’m guessing you’re comparing the results of measures/search_history and issues/search? If so they they’re different because they’re apples and oranges.

The measures history gives you “on this day the value of X was Y”. The issues search gives you “these are the issues that are still open that were created between date A and date B”. So it’s quite natural that the totals returned by the issue search would be lower than those returned by the measure history.

If I have not correctly interpreted this, then please include the actual API calls you’re making (feel free to redact server & just give path & query string) in your reply.


HI @ganncamp

Thanks for the response. I perhaps haven’t explained myself clearly (or perhaps I don’t understand the result properly :slight_smile: ).

I’m expecting to be able to query measures/search_history for two different dates and looking at the Total Open Issues as an example to be able to subtract the later value from the first value and get a number of how many more (or less) open issues there are. I can do this and an example is in my first post.

I was then hoping to see that same number when I query issues/search with the same dates and to see the same number of Open Issues (etc).

These numbers don’t seem to tally up as in my example above.

I hope this helps to explain a bit clearer.


Hi Russ,

Yup. That’s how it works. This web service retrieves the counts that were summed and stored on or about the date in question.

Nope. Not how it works. This web service makes a fresh count every time you call it of the still-Open issues. So when you query for Open issues with a date, you’re asking for all still-Open issues that were created after that date. If I open 8 new issues on Monday and close 3 of them on Wednesday, the most you’ll ever see on Friday is 5.


Thanks for the response, that makes sense.