Metrics (beta)

This feature is in beta

To use this feature, pass in a header including the LD-API-Version key with value set to beta. 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.

List metric groups

Get a list of all metric groups for the specified project.

Expanding the metric groups response

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 group

For example, expand=experiments includes the experiments field in the response.

Filtering metric groups

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.

Sample query

filter=experimentStatus equals 'not_started' and query equals 'metric name'

Request
path Parameters
projectKey
required
string <string>

The project key

query Parameters
filter
string <string>

Accepts filter by experimentStatus and query. Example: filter=experimentStatus equals 'running' and query equals 'test'.

expand
string <string>

A comma-separated list of properties that can reveal additional information in the response.

limit
integer <int64>

The number of metric groups to return in the response. Defaults to 20. Maximum limit is 50.

offset
integer <int64>

Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and returns the next limit items.

Responses
200

Metric group collection response

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

405

Method not allowed

429

Rate limited

get/api/v2/projects/{projectKey}/metric-groups
Request samples
Response samples
application/json
{
  • "items": [
    ],
  • "_links": {
    },
  • "totalCount": 0
}

Create metric group

Create a new metric group in the specified project

Request
path Parameters
projectKey
required
string <string>

The project key

Request Body schema: application/json
required
key
required
string

A unique key to reference the metric group

name
required
string

A human-friendly name for the metric group

kind
required
string

The type of the metric group

Value: "funnel"
description
string

Description of the metric group

maintainerId
required
string

The ID of the member who maintains this metric group

tags
required
Array of strings

Tags for the metric group

required
Array of objects (MetricInMetricGroupInput)

An ordered list of the metrics in this metric group

Responses
201

Metric group response

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

405

Method not allowed

429

Rate limited

post/api/v2/projects/{projectKey}/metric-groups
Request samples
application/json
{
  • "key": "metric-group-key-123abc",
  • "name": "My metric group",
  • "kind": "funnel",
  • "description": "Description of the metric group",
  • "maintainerId": "569fdeadbeef1644facecafe",
  • "tags": [
    ],
  • "metrics": [
    ]
}
Response samples
application/json
{
  • "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
  • "key": "metric-group-key-123abc",
  • "name": "My metric group",
  • "kind": "funnel",
  • "description": "Description of the metric group",
  • "_links": {
    },
  • "_access": {
    },
  • "tags": [
    ],
  • "_creationDate": 0,
  • "_lastModified": 0,
  • "maintainer": {
    },
  • "metrics": [
    ],
  • "_version": 1,
  • "experiments": [
    ],
  • "experimentCount": 0
}

Get metric group

Get information for a single metric group from the specific project.

Expanding the metric group response

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 group
  • experimentCount includes the number of experiments from the specific project that use the metric group

For example, expand=experiments includes the experiments field in the response.

Request
path Parameters
projectKey
required
string <string>

The project key

metricGroupKey
required
string <string>

The metric group key

query Parameters
expand
string <string>

A comma-separated list of properties that can reveal additional information in the response.

Responses
200

Metric group response

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

405

Method not allowed

429

Rate limited

get/api/v2/projects/{projectKey}/metric-groups/{metricGroupKey}
Request samples
Response samples
application/json
{
  • "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
  • "key": "metric-group-key-123abc",
  • "name": "My metric group",
  • "kind": "funnel",
  • "description": "Description of the metric group",
  • "_links": {
    },
  • "_access": {
    },
  • "tags": [
    ],
  • "_creationDate": 0,
  • "_lastModified": 0,
  • "maintainer": {
    },
  • "metrics": [
    ],
  • "_version": 1,
  • "experiments": [
    ],
  • "experimentCount": 0
}

Patch metric group

Patch a metric group by key. Updating a metric group uses a JSON patch representation of the desired changes.

Request
path Parameters
projectKey
required
string <string>

The project key

metricGroupKey
required
string <string>

The metric group key

Request Body schema: application/json
required
Array
op
required
string

The type of operation to perform

path
required
string

A JSON Pointer string specifying the part of the document to operate on

value
any

A JSON value used in "add", "replace", and "test" operations

Responses
200

Metric group response

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

405

Method not allowed

429

Rate limited

patch/api/v2/projects/{projectKey}/metric-groups/{metricGroupKey}
Request samples
application/json
[
  • {
    }
]
Response samples
application/json
{
  • "_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
  • "key": "metric-group-key-123abc",
  • "name": "My metric group",
  • "kind": "funnel",
  • "description": "Description of the metric group",
  • "_links": {
    },
  • "_access": {
    },
  • "tags": [
    ],
  • "_creationDate": 0,
  • "_lastModified": 0,
  • "maintainer": {
    },
  • "metrics": [
    ],
  • "_version": 1,
  • "experiments": [
    ],
  • "experimentCount": 0
}

Delete metric group

Delete a metric group by key.

Request
path Parameters
projectKey
required
string <string>

The project key

metricGroupKey
required
string <string>

The metric group key

Responses
204

Action succeeded

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

405

Method not allowed

429

Rate limited

delete/api/v2/projects/{projectKey}/metric-groups/{metricGroupKey}
Request samples
Response samples
application/json
{
  • "code": "invalid_request",
  • "message": "Invalid request body"
}