Experimentation is an add-on feature
Metrics are necessary components of experiments. Experimentation is available as an add-on for customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.
Metrics track flag behavior over time when an experiment is running. The data generated from experiments gives you more insight into the impact of a particular flag. To learn more, read Creating metrics.
Using the metrics API, you can create, delete, and manage metrics.
Get a list of all metrics for the specified project.
Metrics collection response
Invalid access token
Invalid resource identifier
{- "items": [
- {
- "experimentCount": 0,
- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "custom",
- "_attachedFlagCount": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/metrics/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- null
], - "actions": [
- "*"
], - "notActions": [
- null
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- null
], - "actions": [
- "*"
], - "notActions": [
- null
], - "effect": "string",
- "role_name": "string"
}
}
]
}, - "tags": [ ],
- "_creationDate": 0,
- "lastModified": {
- "date": "2021-08-05T19:46:31.148082Z"
}, - "maintainerId": "569fdeadbeef1644facecafe",
- "_maintainer": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "An",
- "lastName": "Example",
- "role": "admin",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string"
}
], - "_links": {
- "self": {
- "href": "/api/v2/metrics/my-project?limit=20",
- "type": "application/json"
}
}
}
Create a new metric in the specified project. The expected POST
body differs depending on the specified kind
property.
Metric response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Status conflict
Rate limited
{- "eventKey": "trackedClick",
- "isActive": true,
- "isNumeric": false,
- "key": "my-metric",
- "kind": "custom"
}
{- "experimentCount": 0,
- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "custom",
- "_attachedFlagCount": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/metrics/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
]
}, - "tags": [ ],
- "_creationDate": 0,
- "lastModified": {
- "date": "2021-08-05T19:46:31.148082Z"
}, - "maintainerId": "569fdeadbeef1644facecafe",
- "_maintainer": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "An",
- "lastName": "Example",
- "role": "admin",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "experiments": [
- {
- "key": "example-experiment",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "creationDate": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
- "type": "application/json"
}
}
}
], - "isActive": true,
- "_attachedFeatures": [
- {
- "name": "string",
- "key": "string",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}
}
], - "_version": 1,
- "selector": "string",
- "urls": [
- {
- "property1": null,
- "property2": null
}
]
}
Get information for a single metric from the specific project.
LaunchDarkly supports two fields for expanding the "Get metric" response. By default, these fields are not included in the response.
To expand the response, append the expand
query parameter and add a comma-separated list with any of the following fields:
experiments
includes all experiments from the specific project that use the metricexperimentCount
includes the number of experiments from the specific project that use the metricFor example, expand=experiments
includes the experiments
field in the response.
Metric response
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "experimentCount": 0,
- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "custom",
- "_attachedFlagCount": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/metrics/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
]
}, - "tags": [ ],
- "_creationDate": 0,
- "lastModified": {
- "date": "2021-08-05T19:46:31.148082Z"
}, - "maintainerId": "569fdeadbeef1644facecafe",
- "_maintainer": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "An",
- "lastName": "Example",
- "role": "admin",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "experiments": [
- {
- "key": "example-experiment",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "creationDate": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
- "type": "application/json"
}
}
}
], - "isActive": true,
- "_attachedFeatures": [
- {
- "name": "string",
- "key": "string",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}
}
], - "_version": 1,
- "selector": "string",
- "urls": [
- {
- "property1": null,
- "property2": null
}
]
}
Patch a metric by key.
Metric response
Invalid request
Invalid access token
Invalid resource identifier
Status conflict
Rate limited
[- {
- "op": "replace",
- "path": "/name",
- "value": "my-updated-metric"
}
]
{- "experimentCount": 0,
- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "custom",
- "_attachedFlagCount": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/metrics/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
]
}, - "tags": [ ],
- "_creationDate": 0,
- "lastModified": {
- "date": "2021-08-05T19:46:31.148082Z"
}, - "maintainerId": "569fdeadbeef1644facecafe",
- "_maintainer": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "An",
- "lastName": "Example",
- "role": "admin",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "experiments": [
- {
- "key": "example-experiment",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "creationDate": 0,
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
- "type": "application/json"
}
}
}
], - "isActive": true,
- "_attachedFeatures": [
- {
- "name": "string",
- "key": "string",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}
}
], - "_version": 1,
- "selector": "string",
- "urls": [
- {
- "property1": null,
- "property2": null
}
]
}
Delete a metric by key.
Action succeeded
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "code": "unauthorized",
- "message": "Invalid access token"
}