Metrics

List metrics

GET
/api/v2/metrics/{projectKey}

Get a list of all metrics for the specified project.

Filtering metrics

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
dataSourceKeysThe data source that provides events for this metric (for example, "launchdarkly-hosted").anyOf, notEquals
eventKeysThe metric event key.anyOf
eventKindThe metric event kind. One of custom, pageview, click.equals
hasConnectionsWhether the metric has connections to experiments or guarded rollouts. One of true, false.equals
isNumericWhether the metric is numeric. One of true, false.equals
maintainerIdsA comma-separated list of metric maintainer IDs.anyOf
maintainerTeamKeyThe metric maintainer team key.equals
metricUsedInFilter by where the metric is used. One of experiments, guarded_rollouts, any, none.equals
queryA "fuzzy" search across metric key and name. Supply a string or list of strings to the operator.equals
tagsThe metric tags.contains
unitAggregationTypeThe metric's unit aggregation type. One of sum, average.equals
versionIdsThe metric version number.anyOf
viewThe view used to restrict access to the metric.equals

For example, the filter ?filter=tags contains ["tag1", "tag2", "tag3"] matches metrics that have all three tags.

The documented values for filter query parameters are prior to URL encoding. For example, the [ in ?filter=tags contains ["tag1", "tag2", "tag3"] must be encoded to %5B.

Expanding the metric list response

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 metric

For example, expand=experimentCount includes the experimentCount field for each metric in the response.

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Path Parameters

projectKey*string

The project key

Formatstring

Query Parameters

expand?string

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

Formatstring
limit?integer

The number of metrics 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
sort?string

A field to sort the items by. Prefix field by a dash ( - ) to sort in descending order. This endpoint supports sorting by createdAt or name.

Formatstring
filter?string

A comma-separated list of filters. This endpoint accepts filtering by query, tags, eventKind, isNumeric, unitAggregationType, hasConnections, maintainerIds, maintainerTeamKey, view, dataSourceKeys, metricUsedIn, eventKeys, and versionIds. To learn more about the filter syntax, read the 'Filtering metrics' section above.

Formatstring

Response Body

application/json

application/json

application/json

curl -X GET "https://example.com/api/v2/metrics/string"
{  "items": [    {      "experimentCount": 0,      "metricGroupCount": 0,      "activeExperimentCount": 2,      "activeGuardedRolloutCount": 1,      "_id": "5902deadbeef667524a01290",      "_versionId": "version-id-123abc",      "_version": 1,      "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\":\"/my-project/metrics/my-metric/details\",\"type\":\"text/html\"}",      "_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": [],      "_creationDate": "1628192791148",      "lastModified": {        "date": "2021-08-05T19:46:31.148082Z"      },      "maintainerId": "569fdeadbeef1644facecafe",      "_maintainer": "{\"_links\":{\"self\":{\"href\":\"/api/v2/members/569fdeadbeef1644facecafe\",\"type\":\"application/json\"}},\"_id\":\"569fdeadbeef1644facecafe\",\"firstName\":\"Ariel\",\"lastName\":\"Flores\",\"role\":\"owner\",\"email\":\"ariel@acme.com\"}",      "description": "string",      "category": "Error monitoring",      "isNumeric": true,      "successCriteria": "HigherThanBaseline",      "unit": "string",      "eventKey": "Order placed",      "randomizationUnits": [        "user"      ],      "analysisUnits": [        "user"      ],      "filters": "{\"type\":\"group\",\"op\":\"and\",\"values\":[{\"type\":\"contextAttribute\",\"op\":\"in\",\"contextKind\":\"user\",\"attribute\":\"country\",\"values\":[\"JP\"],\"negate\":false},{\"type\":\"eventProperty\",\"op\":\"in\",\"attribute\":\"category\",\"values\":[\"magic-wands\"],\"negate\":false}]}",      "unitAggregationType": "average",      "analysisType": "mean",      "percentileValue": 95,      "eventDefault": {        "disabled": true,        "value": 0      },      "dataSource": {        "key": "string",        "environmentKey": "string",        "_name": "string",        "_integrationKey": "string"      },      "lastSeen": 0,      "archived": true,      "archivedAt": "1609459200000",      "selector": "string",      "urls": "[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]",      "windowStartOffset": 0,      "windowEndOffset": 0,      "winsorLowerPercentile": 1,      "winsorUpperPercentile": 99.5,      "winsorIncludeImputed": false,      "traceQuery": "service.name = \"checkout\"",      "traceValueLocation": "duration",      "unitAggregationField": "string",      "denominator": {        "eventName": "string",        "isNumeric": true,        "unitAggregationType": "string",        "unitAggregationField": "string",        "valueColumn": "string",        "dataSource": {          "key": "string",          "environmentKey": "string",          "_name": "string",          "_integrationKey": "string"        },        "filters": {          "type": "contextAttribute",          "attribute": "country",          "op": "in",          "values": [            "JP"          ],          "contextKind": "user",          "negate": false        },        "windowStartOffset": 0,        "windowEndOffset": 0,        "winsorLowerPercentile": 0,        "winsorUpperPercentile": 0,        "winsorIncludeImputed": true      }    }  ],  "_links": {    "self": {      "href": "/api/v2/metrics/my-project?limit=20",      "type": "application/json"    }  },  "totalCount": 0}