Metrics (beta)

List metric groups

GET
/api/v2/projects/{projectKey}/metric-groups

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

Expanding the metric groups response

This endpoint does not support response expansion.

Although the API accepts an expand query parameter for compatibility reasons, it does not currently modify the response. The parameter is reserved for future use.

Filtering metric groups

The filter parameter supports the following operators: contains, equals, anyOf.

Supported fields and operators

You can only filter certain fields in metrics when using the filter parameter. Additionally, you can only filter some fields with certain operators.

When you search for metrics, the filter parameter supports the following fields and operators:

FieldDescriptionSupported operators
experimentStatusThe experiment's status. One of not_started, running, stopped, started.equals
hasConnectionsWhether the metric group has connections to experiments or guarded rollouts. One of true, false.equals
kindThe metric group kind. One of funnel, standard.equals
maintainerIdsThe metric maintainer IDs.anyOf
maintainerTeamKeyThe metric maintainer team key.equals
queryA "fuzzy" search across metric group key and name. Supply a string or list of strings to the operator.equals

Sorting metric groups

LaunchDarkly supports the following fields for sorting:

  • name sorts by metric group name.
  • createdAt sorts by the creation date of the metric group.
  • connectionCount sorts by the number of connections to experiments the metric group has.

By default, the sort is in ascending order. Use - to sort in descending order. For example, ?sort=name sorts the response by metric group name in ascending order, and ?sort=-name sorts in descending order.

Sample query

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

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Path Parameters

projectKey*string

The project key

Formatstring

Query Parameters

filter?string

Accepts filter by experimentStatus, query, kind, hasConnections, maintainerIds, and maintainerTeamKey. Example: filter=experimentStatus equals 'running' and query equals 'test'.

Formatstring
sort?string

A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order. Read the endpoint description for a full list of available sort fields.

Formatstring
expand?string

This parameter is reserved for future use and is not currently supported on this endpoint.

Formatstring
limit?integer

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

Formatint64
offset?integer

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.

Formatint64

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/api/v2/projects/string/metric-groups"
{  "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": [                "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": "1628192791148",      "_lastModified": "1628192791148",      "maintainer": {        "key": "569fdeadbeef1644facecafe",        "kind": "member",        "_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",          "analysisType": "mean",          "eventKey": "event-key-123abc",          "analysisUnit": "string",          "_links": {            "self": {              "href": "/api/v2/metrics/my-project/my-metric",              "type": "application/json"            }          },          "nameInGroup": "Step 1",          "randomizationUnits": [            "user"          ],          "analysisUnits": [            "user"          ]        }      ],      "_version": 1,      "experiments": [        {          "key": "experiment-key-123abc",          "name": "Example experiment",          "environmentId": "1234a56b7c89d012345e678f",          "environmentKey": "production",          "creationDate": "1654104600000",          "archivedDate": "1654104600000",          "_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,      "activeExperimentCount": 0,      "activeGuardedRolloutCount": 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}

Update layer PATCH

Update a layer by adding, changing, or removing traffic reservations for experiments, or by changing layer name or description. Updating a layer uses the semantic patch format. To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch). ### Instructions Semantic patch requests support the following `kind` instructions for updating layers. <details> <summary>Click to expand instructions for <strong>updating layers</strong></summary> #### updateName Updates the layer name. ##### Parameters - `name`: The new layer name. Here's an example: ```json { "instructions": [{ "kind": "updateName", "name": "New name" }] } ``` #### updateDescription Updates the layer description. ##### Parameters - `description`: The new description. Here's an example: ```json { "instructions": [{ "kind": "updateDescription", "description": "New description" }] } ``` #### updateExperimentReservation Adds or updates a traffic reservation for an experiment in a layer. ##### Parameters - `experimentKey`: The key of the experiment whose reservation you are adding to or updating in the layer. - `reservationPercent`: The amount of traffic in the layer to reserve. Must be an integer. Zero is allowed until iteration start. Here's an example: ```json { "environmentKey": "production", "instructions": [{ "kind": "updateExperimentReservation", "experimentKey": "exp-key", "reservationPercent": 10 }] } ``` #### removeExperiment Removes a traffic reservation for an experiment from a layer. ##### Parameters - `experimentKey`: The key of the experiment whose reservation you want to remove from the layer. Here's an example: ```json { "environmentKey": "production", "instructions": [{ "kind": "removeExperiment", "experimentKey": "exp-key" }] } ``` </details>

Create metric group POST

Create a new metric group in the specified project