Monitoring custom metrics of a Project


I am using Sonarqube to analyse few different projects (Scala/Java/.Net) with usually default scanners etc. but on more than few occasions I would like to calculate some custom metric and have it monitored also on Sonarqube.

It usually is something like load-test-index, test-duration, or whatever else I measure during tests execution and I would like to see a trend/history values during development of particular Project.

Up until now I was using api/custom_measures which I just learned is deprecated since 7.4.
I have Quality Gates created based on those measures and to be honest freedom and flexibility that
these API provides is really good.

Can you point me to any other solution that would satisfy my needs?
I would like to use something which won’t be deleted soon :slight_smile:

Or is this API truly needed to be removed? What’s the alternative?


Hi Przemek,

Welcome to the community!

Custom measures are deprecated, but I can’t give you a timeline on their removal right now. That doesn’t mean they won’t be removed, only that I can’t tell you when.

Given what you describe, your best bet is to create a custom plugin. I’m really not the best one to give you pointers on that, but there’s a whole category dedicated to the topic. :slight_smile:


Hi Ann,

Thank you very much for the reply!

So I guess I will keep using this API until I am forced to create a plugin :slight_smile:

Are there any hard reasons for deprecating it?
If you asked me I would vote for de-deprecation :smiley:


Hi Przemek,

The reason for deprecation is that that you seem to be in a tiny minority of actually using this for code quality-related metrics. The vast majority of people seem to use it as a labeling / grouping system, and… well, there are project labels now. AND there’s the ability to create custom metrics via a plugin.

Really, for your use case you have to admit that custom measures are a bit awkward. After all, for your use case you need to

  • compute the values before analysis
  • use web services to push the values before analysis
  • wait until after analysis for the values to actually “take”

This is as opposed to calculating and storing the values as part of analysis.

And by the way,

I really wouldn’t leave this to the last minute. Just because I can’t give you a timeline right now that doesn’t mean it won’t be removed in 8.0, or 8.1, or…


Hi Ann,

I can imagine that my use case is in tiny minority, but on the other hand that is not really a reason to deprecate a functionality, which has no real replacement. While I can write custom plugin, but creating one, maintaining it, installing on server etc. is vastly more complicated then using existing API.

Second point while true, is entirely not an issue, as I still have to execute tests before analysis (to calculate code coverage), so I just run one simple curl after such tests, then analysis, then I get all needed values after given build.


I also agree with Przemek there is really no alternative to the custom metric that you can inject into a project. This API provides many uses e.g. other quality tools which have data about a development team contributing to the sonar project. That data can be extracted using that specific tool API e.g. JIRA filters to retrieve data about a project and then individual values / metrics can be assigned. You can then easily correlate sonar internal code quality data e.g. coverage / issue violations / types with those JIRA metrics e.g. defects injected / time to resolve defects. This can be very interesting looking at a project holistically.

The API makes this easy to add whereas a custom plug in for each use case is vastly more complicated for such a generic feature

I agree with you, przemekak and Mattadamson,
I need to use custom metrics/measures in SQ 7.9 and now …
G Ann Campbell, what do you mean when you say

use web services to push the values before analysis

Im looking for this in “web api” documentation and is ‘deprecated’ (in 7.9)

POST api/custom_measures/update
since 5.2 deprecated since 7.4
Update a custom measure. Value and/or description must be provided
Requires ‘Administer System’ permission or ‘Administer’ permission on the project.

POST api/metrics/update
since 5.2 deprecated since 7.7
Update a custom metric.
Requires ‘Administer System’ permission.

So what is the alternative to configure / push the value??

I’m new with sonarqube, and some technical details are a bit confuse to me, so sorry if I’m misunderstanding something


Hi @menos_16,

Welcome to the community!

Yup. The whole feature is deprecated & thus also the supporting web services.

If you want to use this deprecated feature, then those deprecated web services are how you’d go about it if you need to push new values from your CI just before anlaysis.

If you want to get ahead of the curve & start with something that’s not deprecated, then you’ll need to write a custom plugin. If you decide to go that route, feel free to open new threads with specific development questions.