Available for Pro and Enterprise plans
Metrics are necessary components of experiments. Experimentation is available to customers on a Pro or Enterprise plan. To learn more, read about our pricing. To add Experimentation to 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.
Are you importing metric events?
If you want to import metric events into LaunchDarkly from an existing data source, use the metric import API. To learn more, read Importing metric events.
Get a list of all metrics for the specified project.
LaunchDarkly supports expanding the "List metrics" response. By default, the expandable field is not included in the response.
To expand the response, append the expand
query parameter and add the following supported field:
experimentCount
includes the number of experiments from the specific project that use the metricFor example, expand=experimentCount
includes the experimentCount
field for each metric in the response.
Metrics collection response
Invalid access token
Invalid resource identifier
{- "items": [
- {
- "experimentCount": 0,
- "_id": "5902deadbeef667524a01290",
- "key": "metric-key-123abc",
- "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": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "randomizationUnits": [
- "user"
]
}
], - "_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": "metric-key-123abc",
- "kind": "custom"
}
{- "experimentCount": 0,
- "_id": "5902deadbeef667524a01290",
- "key": "metric-key-123abc",
- "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": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "randomizationUnits": [
- "user"
], - "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "creationDate": 0,
- "archivedDate": 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": "metric-key-123abc",
- "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": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "randomizationUnits": [
- "user"
], - "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "creationDate": 0,
- "archivedDate": 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": "metric-key-123abc",
- "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": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "description": "string",
- "isNumeric": true,
- "successCriteria": "HigherThanBaseline",
- "unit": "string",
- "eventKey": "string",
- "randomizationUnits": [
- "user"
], - "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "creationDate": 0,
- "archivedDate": 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"
}