How to get Sonarqube Metrics (i.e. vulnerabilities: A; B; C; D; E) Ratings via the web api

1.6k Views Asked by At

Please assist with the above. I have successfully implemented a web api to sonarqube and I am able to get values for the metrics I specify in the web api (ref: https://gazelle.ihe.net/sonar/web_api/api/measures)

The problem I have is, I want to get the metrics ratings (i.e A; B; C; D) for each metric. and the api only returns the values and not the ratings.

I also tried using component_tree and type by the ratings are not returned.

Please assist:)

1

There are 1 best solutions below

1
On BEST ANSWER

The answer to this question is as follows:

  • The 'vulnerabilities' ratings (A,B,C,D,E) are represented by the metricKey 'security_rating', as vulnerabilities are under Security in sonarqube
  • Web API Request call: sonarqubeurl/api/measures/component?metricKeys=security_rating
  • The 'security_rating' is structured as follows: (1=A,2=B,3=C,4=D,5=E), it returns numbers (corresponding to the alphabets) instead of alphabets.

I hope this helps others as well