Count Severities of Issues in SonarQube Through Restful Webservice

2,579 views
Skip to first unread message

jaynra...@gmail.com

unread,
Oct 26, 2016, 8:33:18 AM10/26/16
to SonarQube
HI All,

I want to get Dashboard related details of sonarqube through Restful Webservice.

I have got some data through :http://<ServerAddress:port>/api/measures/component?componentKey=<projectname>&metricKeys=violations,ncloc,line
Above url gives me data like total issues, line of code etc.

I want to get total number of issues related to severities like, INFO=123,CRITICAL=100,BLOCKER-50 etc.
Can anyone help on finding right url to get these details?

My findings : I tried this URL but not working,http://<ServerAddress:port>/api/issues/search?facets=severities&facetMode=count

Julien Lancelot

unread,
Oct 26, 2016, 9:17:25 AM10/26/16
to jaynra...@gmail.com, SonarQube
Hi,

The last WS (api/issues/search) you've talked about should worked, could you please elaborate what is not working using it ?

Regards,

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/ac8a0c32-bd7c-4772-9f2a-ee539d8c0adc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Julien LANCELOT | SonarSource

Jay Raithatha

unread,
Oct 27, 2016, 1:15:59 AM10/27/16
to SonarQube, jaynra...@gmail.com
Hi Julien,

Thanks for quick reply...!!

if I use WS (api/issues/search), I am getting all issues with their respective severity, but what I want is the total count as per severity like if I have total 100 issues, 10 out of 100 is INFO, 60 out of 100 is BLOCKER, 30 out of 100 is CRITICAL....

In previous version of Sonar 4.5, we were getting data like this in xml format. like <severity>Info</severity><value>10</value>, as xml is deprecated in new version, I think there should be a way to get similar result in JSON format.

Let me know if you need more clarification.

Julien Lancelot

unread,
Oct 27, 2016, 2:50:29 AM10/27/16
to Jay Raithatha, SonarQube
Hi Jay,

In order to get number of issues by severities, you need to use the 'facets' parameter of the api/issues/search WS.
For instance, to have this info from all your issues, you'll do http://localhost:9000/api/issues/search?facets=severities.

Regards,



For more options, visit https://groups.google.com/d/optout.

Jay Raithatha

unread,
Oct 27, 2016, 4:41:13 AM10/27/16
to SonarQube
Hi Julien,

Thanks for response, Now  I am able to get severities. One more little help on specific project related total severities.

I have tried : http://localhost:9000/api/issues/search?facets=severities&componentkeys=<project-name>&onComponentOnly=(yes/no/true/false)

But I am not able to get total severity values as per mentioned project's dashboard. I am always getting total severities of all projects.

Thanks in advance.

Julien Lancelot

unread,
Oct 27, 2016, 4:45:26 AM10/27/16
to Jay Raithatha, SonarQube
Hi,

There's a typo in the parameter : you should use componentKeys instead of componentkeys.

Regards,

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jay Raithatha

unread,
Oct 27, 2016, 8:53:12 AM10/27/16
to SonarQube
HI Julien,

Silly me....Thanks a lot...!!

But now i am facing another problem, in dashboard I have, Total issues : 3395,Blocker : 3,Critical :1269,Major :1846,Minor: 277,Info :0
in url : http://localhost:9000/api/measures/component?componentKey=<cmp Key>&metricKeys=violations
Here result is : 3395,

But if i use this to get severities: http://localhost:9000/api/issues/search?facets=severities&componentKeys=<cmp Key>(using same component Key)
I am getting different number of all severities. They total to 4059 as well.

I am not able to understand that if for first url componenet key is giving correct data why I am not getting in second URL.

On Wednesday, 26 October 2016 13:33:18 UTC+1, Jay Raithatha wrote:

Julien Lancelot

unread,
Nov 8, 2016, 3:55:56 AM11/8/16
to Jay Raithatha, SonarQube
Hi Jay,

Sorry for the late answer.

You can have some difference when using the measures WS and when using the issues WS : the first one is getting data from analysis when the second one is using "real time" data => that means that if some issues have been resolved (Won't Fix or False Positive), as long as the project haven't been analyzed you'll get such differences.

Please analyse again your project and check values returned by the 2 WS.

Regards,

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages