This an an archived version of the documentation for SonarQube version 4.3 and below.
See https://docs.sonarqube.org/display/SONAR/Documentation for current functionality
Get a List of Metrics
Description | Get a list of metrics |
URL | /api/metrics |
HTTP Method | GET |
Response Formats | json | xml |
Security | None |
Examples
Use Case | Example Request |
---|---|
Get all the metrics from the SonarQube Nemo instance | |
Get the metric 'Lines of Code' (key = ncloc) |
Response Format
[ { "key":"packages", "name":"Packages", "description":"Packages", "domain":"Size", "qualitative":false, "user_managed":false, "direction":-1, "val_type":"INT", "hidden":false }, ... ]
Parameters
Parameter | Description | Required | Default Value | Example Value |
---|---|---|---|---|
key | key of the metric | No. Get all metrics if not set | None | ncloc |
format | Response format can be set through:
If nothing is set, json is used. | No | None | json |
Create a Manual Metric
Description | Create a manual metric |
URL | /api/metrics |
HTTP Method | POST |
Security | Requires Administer System permission |
Examples
Use Case | Example Request |
---|---|
Create a manual metric:
|
|
Parameters
Parameter | Description | Required | Default Value | Example Value |
---|---|---|---|---|
id | Key of the manual metric. | Yes | None | foo |
name | Name of the manual metric. | Yes | None | bar |
val_type | Type of the manual metric. Possible valules: INT | BOOL | FLOAT | PERCENT | STRING | LEVEL | Yes | None | INT |
description | Description of the manual metric. | No | None | blabla |
domain | Domain of the manual metric. | No | None | Size |
Update a Manual Metric
Description | Update a manual metric |
URL | /api/metrics |
HTTP Method | PUT |
Security | Requires Administer System permission |
Examples
Use Case | Example Request |
---|---|
Update the manual metric whose key is 'foo':
|
|
Parameters
Parameter | Description | Required | Default Value | Example Value |
---|---|---|---|---|
id | Key of the manual metric. | Yes | None | foo |
name | Name of the manual metric. | Yes | None | bar |
val_type | Type of the manual metric. Possible valules: INT | BOOL | FLOAT | PERCENT | STRING | LEVEL | Yes | None | INT |
description | Description of the manual metric. | No | None | blabla |
domain | Domain of the manual metric. | No | None | Size |
Delete a Manual Metric
Description | Delete a manual metric |
URL | /api/metrics |
HTTP Method | DELETE |
Security | Requires Administer System permission |
Examples
Use Case | Example Request |
---|---|
Delete the manual metric whose key is 'foo'. |
|
Parameters
Parameter | Description | Required | Default Value | Example Value |
---|---|---|---|---|
id | Key of the manual metric. | Yes | None | foo |