Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
titleTable of Contents

Table of Contents
maxLevel1

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 Sonar SonarQube Nemo instance

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

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

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

...

Parameter

Description

Required

Default Value

Example Value

idkey

id or key of the metric

No. Get all metrics if not set

None

ncloc

format

Response format

.
Possible values

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 Administer System permission

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 Administer System permission

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 Administer System permission

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