This feature is in beta
To use this feature, pass in a header including the
LD-API-Version
key with value set tobeta
. Use this header with each call. To learn more, read Beta resources.Resources that are in beta are still undergoing testing and development. They may change without notice, including becoming backwards incompatible.
Metrics measure audience behaviors affected by the flags in your experiments. Metric groups are reusable, ordered lists of metrics you can use to standardize metrics across multiple experiments. To learn more, read Metrics and Metric groups.
Using the metrics API, you can create, delete, and manage metrics and metric groups.
Get a list of all metric groups for the specified project.
LaunchDarkly supports one field for expanding the "Get metric groups" 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 the following field:
experiments
includes all experiments from the specific project that use the metric groupFor example, expand=experiments
includes the experiments
field in the response.
The filter
parameter supports the equals
operator on the following fields: experimentStatus
, query
.
The experimentStatus
field supports the following values: not_started
, running
, stopped
, and started
.
The query
field is a search query that is compared against the metric group name and key.
filter=experimentStatus equals 'not_started' and query equals 'metric name'
Metric group collection response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Method not allowed
Rate limited
{- "items": [
- {
- "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
- "key": "metric-group-key-123abc",
- "name": "My metric group",
- "kind": "funnel",
- "description": "Description of the metric group",
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/metric-groups/my-metric-group",
- "type": "application/json"
}
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- null
], - "actions": [
- "*"
], - "notActions": [
- null
], - "effect": "allow",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- null
], - "actions": [
- "*"
], - "notActions": [
- null
], - "effect": "allow",
- "role_name": "string"
}
}
]
}, - "tags": [
- "ops"
], - "_creationDate": 0,
- "_lastModified": 0,
- "maintainer": {
- "member": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "team": {
- "customRoleKeys": [
- "access-to-test-projects"
], - "key": "team-key-123abc",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "name": "QA Team"
}
}, - "metrics": [
- {
- "key": "metric-key-123abc",
- "_versionId": "version-id-123abc",
- "name": "Example metric",
- "kind": "custom",
- "isNumeric": true,
- "unitAggregationType": "sum",
- "_links": {
- "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "nameInGroup": "Step 1",
- "randomizationUnits": [
- "user"
]
}
], - "_version": 1,
- "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "environmentKey": "production",
- "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"
}
}
}
], - "experimentCount": 0
}
], - "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/metric-groups",
- "type": "application/json"
}
}, - "totalCount": 0
}
Create a new metric group in the specified project
Metric group response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Method not allowed
Rate limited
{- "key": "metric-group-key-123abc",
- "name": "My metric group",
- "kind": "funnel",
- "description": "Description of the metric group",
- "maintainerId": "569fdeadbeef1644facecafe",
- "tags": [
- "ops"
], - "metrics": [
- {
- "key": "metric-key-123abc",
- "nameInGroup": "Step 1"
}
]
}
{- "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
- "key": "metric-group-key-123abc",
- "name": "My metric group",
- "kind": "funnel",
- "description": "Description of the metric group",
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/metric-groups/my-metric-group",
- "type": "application/json"
}
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "allow",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "allow",
- "role_name": "string"
}
}
]
}, - "tags": [
- "ops"
], - "_creationDate": 0,
- "_lastModified": 0,
- "maintainer": {
- "member": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "team": {
- "customRoleKeys": [
- "access-to-test-projects"
], - "key": "team-key-123abc",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "name": "QA Team"
}
}, - "metrics": [
- {
- "key": "metric-key-123abc",
- "_versionId": "version-id-123abc",
- "name": "Example metric",
- "kind": "custom",
- "isNumeric": true,
- "unitAggregationType": "sum",
- "_links": {
- "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "nameInGroup": "Step 1",
- "randomizationUnits": [
- "user"
]
}
], - "_version": 1,
- "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "environmentKey": "production",
- "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"
}
}
}
], - "experimentCount": 0
}
Get information for a single metric group from the specific project.
LaunchDarkly supports two fields for expanding the "Get metric group" 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 either or both of the following fields:
experiments
includes all experiments from the specific project that use the metric groupexperimentCount
includes the number of experiments from the specific project that use the metric groupFor example, expand=experiments
includes the experiments
field in the response.
Metric group response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Method not allowed
Rate limited
{- "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
- "key": "metric-group-key-123abc",
- "name": "My metric group",
- "kind": "funnel",
- "description": "Description of the metric group",
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/metric-groups/my-metric-group",
- "type": "application/json"
}
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "allow",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "allow",
- "role_name": "string"
}
}
]
}, - "tags": [
- "ops"
], - "_creationDate": 0,
- "_lastModified": 0,
- "maintainer": {
- "member": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "team": {
- "customRoleKeys": [
- "access-to-test-projects"
], - "key": "team-key-123abc",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "name": "QA Team"
}
}, - "metrics": [
- {
- "key": "metric-key-123abc",
- "_versionId": "version-id-123abc",
- "name": "Example metric",
- "kind": "custom",
- "isNumeric": true,
- "unitAggregationType": "sum",
- "_links": {
- "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "nameInGroup": "Step 1",
- "randomizationUnits": [
- "user"
]
}
], - "_version": 1,
- "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "environmentKey": "production",
- "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"
}
}
}
], - "experimentCount": 0
}
Patch a metric group by key. Updating a metric group uses a JSON patch representation of the desired changes.
Metric group response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Method not allowed
Rate limited
[- {
- "op": "replace",
- "path": "/name",
- "value": "my-updated-metric-group"
}
]
{- "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
- "key": "metric-group-key-123abc",
- "name": "My metric group",
- "kind": "funnel",
- "description": "Description of the metric group",
- "_links": {
- "parent": {
- "href": "/api/v2/projects/my-project",
- "type": "application/json"
}, - "self": {
- "href": "/api/v2/projects/my-project/metric-groups/my-metric-group",
- "type": "application/json"
}
}, - "_access": {
- "denied": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "allow",
- "role_name": "string"
}
}
], - "allowed": [
- {
- "action": "string",
- "reason": {
- "resources": [
- "proj/*:env/*;qa_*:/flag/*"
], - "notResources": [
- "string"
], - "actions": [
- "*"
], - "notActions": [
- "string"
], - "effect": "allow",
- "role_name": "string"
}
}
]
}, - "tags": [
- "ops"
], - "_creationDate": 0,
- "_lastModified": 0,
- "maintainer": {
- "member": {
- "_links": {
- "self": {
- "href": "/api/v2/members/569f183514f4432160000007",
- "type": "application/json"
}
}, - "_id": "569f183514f4432160000007",
- "firstName": "Ariel",
- "lastName": "Flores",
- "role": "admin",
- "email": "ariel@acme.com"
}, - "team": {
- "customRoleKeys": [
- "access-to-test-projects"
], - "key": "team-key-123abc",
- "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "name": "QA Team"
}
}, - "metrics": [
- {
- "key": "metric-key-123abc",
- "_versionId": "version-id-123abc",
- "name": "Example metric",
- "kind": "custom",
- "isNumeric": true,
- "unitAggregationType": "sum",
- "_links": {
- "self": {
- "href": "/api/v2/metrics/my-project/my-metric",
- "type": "application/json"
}
}, - "nameInGroup": "Step 1",
- "randomizationUnits": [
- "user"
]
}
], - "_version": 1,
- "experiments": [
- {
- "key": "experiment-key-123abc",
- "name": "Example experiment",
- "environmentId": "1234a56b7c89d012345e678f",
- "environmentKey": "production",
- "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"
}
}
}
], - "experimentCount": 0
}
Delete a metric group by key.
Action succeeded
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Method not allowed
Rate limited
{- "code": "invalid_request",
- "message": "Invalid request body"
}