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 response JSON
Invalid access token
Invalid resource identifier
curl -i -X GET \ 'https://app.launchdarkly.com/api/v2/metrics/{projectKey}' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "items": [
- {
- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "pageview",
- "_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": [
- null
], - "notResources": [
- null
], - "actions": [
- null
], - "notActions": [
- null
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- null
], - "notResources": [
- null
], - "actions": [
- null
], - "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": "owner",
- "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.
Successful metric response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Status conflict
Rate limited
{- "key": "my-metric",
- "kind": "pageview",
- "urls": [
- {
- "kind": "substring",
- "substring": "foo"
}
]
}
{- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "pageview",
- "_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": [
- "string"
], - "notResources": [
- "string"
], - "actions": [
- "string"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "string"
], - "notResources": [
- "string"
], - "actions": [
- "string"
], - "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": "owner",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "isActive": true,
- "_attachedFeatures": [
- {
- "name": "string",
- "key": "string",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}
}
], - "_version": 0,
- "selector": "string",
- "urls": [
- {
- "property1": null,
- "property2": null
}
]
}
Get information for a single metric from the specific project.
Metric response JSON
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
curl -i -X GET \ 'https://app.launchdarkly.com/api/v2/metrics/{projectKey}/{metricKey}' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "pageview",
- "_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": [
- "string"
], - "notResources": [
- "string"
], - "actions": [
- "string"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "string"
], - "notResources": [
- "string"
], - "actions": [
- "string"
], - "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": "owner",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "isActive": true,
- "_attachedFeatures": [
- {
- "name": "string",
- "key": "string",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}
}
], - "_version": 0,
- "selector": "string",
- "urls": [
- {
- "property1": null,
- "property2": null
}
]
}
Patch a metric by key.
Metric response JSON
Invalid request
Invalid access token
Invalid resource identifier
Status conflict
Rate limited
[- {
- "op": "replace",
- "path": "/name",
- "value": "my-updated-metric"
}
]
{- "_id": "5902deadbeef667524a01290",
- "key": "my-metric",
- "name": "my-metric",
- "kind": "pageview",
- "_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": [
- "string"
], - "notResources": [
- "string"
], - "actions": [
- "string"
], - "notActions": [
- "string"
], - "effect": "string",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "string"
], - "notResources": [
- "string"
], - "actions": [
- "string"
], - "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": "owner",
- "email": "a.example@example.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "isActive": true,
- "_attachedFeatures": [
- {
- "name": "string",
- "key": "string",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "_site": {
- "href": "string",
- "type": "string"
}
}
], - "_version": 0,
- "selector": "string",
- "urls": [
- {
- "property1": null,
- "property2": null
}
]
}
Delete a metric by key.
Action succeeded
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
curl -i -X DELETE \ 'https://app.launchdarkly.com/api/v2/metrics/{projectKey}/{metricKey}' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "code": "unauthorized",
- "message": "invalid key"
}