Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

...

languagenone

GET

...

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

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

...

languagenone

...

Response Format

Code Block
titleJSON
languagejavascript
[
  {
    "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

id

id or key of the projectmetric

No. Get all metrics if not set

None

ncloc

formatResponse formatsformat.
Possible values: xml or | json
NoxmlNone json

Create a Metric

DescriptionCreate a metric

URL

/api/metrics

HTTP MethodPOST
 Security

Requires Global Administrator role

Examples

Use CaseExample Request
Create a metric

...

?Q?

...

...

???
 

Code Block
languagenone
??????????????????????????????,

Parameters

Parameter

Description

Required

Default ValueExample Value

description

Description of the metric

 

NoneMy metric blabla

direction

Possible values: -1 | 0 | 1

 None-1

domain 

Domain of the metric

 NoneSize
name Name of the metricYesNonemyMetric

qualitative

Is it a qualitative metric?
Possible values: 0 | 1

 None1
val_type

Value type.
Possible values: PERCENT , | INT , | FLOAT , | STRING , | BOOL , | MILLISEC

YesNonePERCENT
user_definedCan user fill measures online?
Possible values: true | false 
Nofalsetrue

Update a Metric

DescriptionUpdate a metric

URL

/api/metrics

HTTP MethodPUT
 Security

Requires Global Administrator role

Examples

  1. Update metric 'myMetric':
    • ???
    • ???
    • ???
       

      Code Block
      languagenone
      ??????????????????????????????,

Parameters

Parameter

Description

Required

Default Value
idid of the metricYesNone

description

Description of the metric

No 

None

direction

Possible values: -1, 0, 1

No None

domain

 

No None
name NoNone

qualitative

Is it a qualitative metric?
Possible values: 0, 1

No None
val_type

Value type.
Possible values: PERCENT, INT, FLOAT, STRING, BOOL, MILLISEC

No None
user_definedCan user fill measures online?
Possible values: true, false 
No None
Use CaseExample Request
Create a metric

?Q?

Parameters

?Q?


Delete a Metric

DescriptionDelete a metric

URL

/api/metrics

HTTP MethodDELETE
 Security

Requires Global Administrator role

Examples

Use CaseExample Request
Delete metric 'myMetric'

...

...

languagenone

curl

...

-u

...

admin:admin

...

-X

...

DELETE

...

http://localhost:9000/api/metrics/myMetric

Parameters

Parameter

Description

Required

Default ValueExample Value
idid of the metricYesNonemyMetric