Full documentation for SonarQube has moved to a new location: http://docs.sonarqube.org/display/SONAR

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

Table of Contents

Get a List of Metrics

DescriptionGet a list of metrics

URL

/api/metrics

HTTP MethodGET
Response Formatsjson | xml

Security

None

 

Examples

Use CaseExample Request
Get all the metrics from the SonarQube Nemo instance

GET http://nemo.sonarsource.org/api/metrics

Get the metric 'Lines of Code' (key = ncloc)

GET http://nemo.sonarsource.org/api/metrics/ncloc

Response Format

JSON

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:

  • Parameter format: xml | json
  • Or the 'Accept' property in the HTTP header:
    • Accept:text/xml
    • Accept:application/json
If nothing is set, json is used.
NoNonejson

Create a Manual Metric

DescriptionCreate a manual metric

URL

/api/metrics

HTTP MethodPOST

Security

Requires authentication and System Administrator role

Examples

Use CaseExample Request

Create a manual metric:

  • Key: foo
  • Name: bar
  • Value type: INT
  • Description: blabla
  • Domain: Size

curl -X POST -v -u admin:admin 'http://localhost:9000/api/metrics/foo?name=bar&val_type=INT&description=blabla&domain=Size'

Parameters

Parameter

Description

Required

Default Value

Example Value

key

Key of the manual metric.

Yes

None

foo

nameName of the manual metric.YesNonebar
val_type

Type of the manual metric.

Possible valules: INT | BOOL | FLOAT | PERCENT | STRING | LEVEL

YesNoneINT
descriptionDescription of the manual metric.NoNoneblabla
domainDomain of the manual metric.NoNoneSize

Update a Manual Metric

DescriptionUpdate a manual metric

URL

/api/metrics

HTTP MethodPUT

Security

Requires authentication and System Administrator role

Examples

Use CaseExample Request

Update the manual metric whose key is 'foo':

  • New name: bar
  • New value type: INT
  • New description: blabla
  • New domain: Size

curl -X PUT -v -u admin:admin 'http://localhost:9000/api/metrics/foo?name=bar&val_type=INT&description=blabla&domain=Size'

Parameters

Parameter

Description

Required

Default Value

Example Value

key

Key of the manual metric.

Yes

None

foo

nameName of the manual metric.YesNonebar
val_type

Type of the manual metric.

Possible valules: INT | BOOL | FLOAT | PERCENT | STRING | LEVEL

YesNoneINT
descriptionDescription of the manual metric.NoNoneblabla
domainDomain of the manual metric.NoNoneSize

Delete a Manual Metric

DescriptionDelete a manual metric

URL

/api/metrics

HTTP MethodDELETE

Security

Requires authentication and System Administrator role

Examples

Use CaseExample Request

Delete the manual metric whose key is 'foo'.

curl -X DELETE -v -u admin:admin 'http://localhost:9000/api/metrics/foo'

Parameters

Parameter

Description

Required

Default Value

Example Value

key

Key of the manual metric.

Yes

None

foo

  • No labels