I need to get the value of a few metrics for a specific component (a specific java class) for each analysis.
As an example, I need to get something like:
Analysis
Component
Complexity
ncloc
f1234
/mypackage/a.java
10
150
f1235
/mypackage/a.java
10
155
I can get the details of the metric, I guess related to the last analysis.
Here is the API call I am using for the details. As an example, I can get
Metrics: complexity and ncloc
componentKey: org:apache:zookeper2:src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java
http://sonar63.rd.tut.fi/api/measures/component?metricKeys=complexity,ncloc&componentKey=org:apache:zookeper2:src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java
Does anybody know how to get the same metrics for all the analysis or for a specific analysis?
I might get the list of analysis with the api http://sonar63.rd.tut.fi/api/project_analyses/search?project=org:apache:zookeper2&ps=500 but I cannot find a way to pass the analysis id to the measures api.
You should try api/measures/search_history endpoint. You should be able to reach documentation at <sonarqube_instance_url>/web_api/api/measures/search_history.
Related
I need to get the rating value from Booking.com system for specific property. Is there an API that provides information such as overall rating and other useful information for properties that are listed in their system?
In case anyone has the same question I will answer in short - the booking.com API is not public! In order to get access you need to write them an email and provide a lot of information about why you're going to use it, how and who is going to use it. Describe your business model etc. Also you need to producing an average of 500 bookings per month. Then wait an approval process.
I decided to simple parse the website and get the overall rating.
I'd like to retrieve multiple metrics for ALL projects in SQ in one GET request. Is this possible?
It seems like GET api/measures/component can give me the XML I want, but only if given a specific componentKey (project name). The only other alternative seems to be to go one by one through each component, which wouldn't be ideal given that I have over 500 projects I would like get metrics for.
What you're asking for is not possible. You'll have to query the api/measures/component many times to get all measures from all projects.
I'm trying to solve one task and will appreciate any help - links to documentation, or links to forums, or other FAQs besides https://cwiki.apache.org/confluence/display/NIFI/FAQs, or any meaningful answer in this post =) .
So, I have the following task:
Initial part of my system collects data each 5-15 min from different DB sources. Then I remove duplicates, remove junk, combine data from different sources according to logic and then redirect it to second part of the system as several streams.
As far as I know, "NiFi" can do this task in the best way =).
Currently I can successfully get information from InfluxDB by "GetHTTP" processor. However I can't configure same kind of processor for getting information from Elastic DB with all necessary options. I'd like to receive data each 5-15 minutes for time period from "now-minus-<5-15 minutes>" to "now". (depends on scheduler period) with several additional filters. If I understand it right, this can be achieved either by subscription to "_index" or by regular requests to DB with desired interval.
I know that NiFi has several specific Processors designed for Elasticsearch (FetchElasticsearch5, FetchElasticsearchHttp, QueryElasticsearchHttp, ScrollElasticsearchHttp) as well as GetHTTP and PostHTTP Processors. However, unfortunately, I have lack of information or even better - examples - how to configure their "Properties" for my purposes =(.
What's the difference between FetchElasticsearchHttp, QueryElasticsearchHttp? Which one fits better for my task? What's the difference between GetHTTP and QueryElasticsearchHttp besides several specific fields? Will GetHTTP perform the same way if I tune it as I need?
Any advice?
I will be grateful for any help.
The ElasticsearchHttp processors try to make it easier to interact with ES by generating the appropriate REST API call based on the properties you set. If you know the full URL you need, you could use GetHttp or InvokeHttp. However the ESHttp processors let you put in just the stuff you're looking for, and it will generate the URL and return the results.
FetchElasticsearch (and its variants) is used to get a particular document when you know the identifier. This is sometimes used after a search/query, to return documents one at a time after you know which ones you want.
QueryElasticsearchHttp is for when you want to do a Lucene-style query of the documents, when you don't necessarily know which documents you want. It will only return up to the value of index.max_result_window for that index. To get more records, you can use ScrollElasticsearchHttp afterwards. NOTE: QueryElasticsearchHttp expects a query that will work as the "q" parameter of the URL. This "mini-language" does not support all fields/operators (see here for more details).
For your use case, you likely need InvokeHttp in order to issue the kind of query you describe. This article describes how to issue a query for the last 15 minutes. Once your results are returned, you might need some combination of EvaluateJsonPath and/or SplitJson to work with the individual documents, see the Elasticsearch REST API documentation (and NiFi processor documentation) for more details.
I am trying to use the SonarQube web service API api/issues/search to extract the information of all issues. But I see that the maximum number of results from the API is only 500 with filters like pageSize.
Is there a different way of using this API so that I can get all the issues in the resultlist?
The web service results are paginated. Use ps (page size) and p to step through the result set.
That said, there's a hard limit of 10k.
For my release automation i'm creating a document generator that includes the current measurements from sonarqube. In this document i would like to report the differences between several versions of the code.
I managed to get the list of versions without any problem using
http://nemo.sonarqube.org/api/events?resource=org.codehaus.sonar:sonar&categories=Version
And i also managed to get a measurement of the current code state using
http://nemo.sonarqube.org/api/resources?resource=org.codehaus.sonar:sonar&metrics=ncloc
Can anybody help me in how to get the ncloc of an older version, say version '4.0'?
The Web Service does not allow to query this information.
Well the solution is roundabout but you could get the data you desire based on the version.
Proposed solution:
Get the version-specific details from the API.
http://nemo.sonarqube.org/api/events?resource=org.codehaus.sonar:sonar&categories=Version&format=json
The response would be something like:
[{"id":"23761","rk":"helloworld","n":"1.1","c":"Version","dt":"2017-07-19T20:28:54-0500"},
{"id":"23731","rk":"helloworld","n":"1.0","c":"Version","dt":"2017-07-18T14:51:20-0500"},
{"id":"5107","rk":"helloworld","n":"1","c":"Version","dt":"2015-12-07T11:37:44-0600"}]
The "dt" value specifies the point of time where the Version is released.
Parse the JSON and get the dt values. Find the minimum and maximum date values from the obtained dt values.
Use the time machine API to query out the metrics you need using the API
http://nemo.sonarqube.org/api/timemachine?resource=helloworld&metrics=coverage,ncloc&rfomDateTime=(min_dt_value)&toDateTime=(max_dt_value)
You will get all the metrics between the timestamps.
Compare our version-specific dt values against the one obtained from the above response and thus get the version specific metric values.