Create metric
Create a new metric in the specified project. The expected POST body differs depending on the specified kind property.
Authorizations
Path Parameters
The project key
Body
A unique key to reference the metric
"metric-key-123abc"
The kind of event your metric will track
pageview, click, custom, trace "custom"
A human-friendly name for the metric
"Example metric"
Description of the metric
"optional description"
One or more CSS selectors. Required for click metrics only.
".dropdown-toggle"
One or more target URLs. Required for click and pageview metrics only.
"invalid example"
Whether to track numeric changes in value against a baseline (true) or to track a conversion when an end user takes an action (false). Required for custom and trace metrics only.
false
The unit of measure. Applicable for numeric custom and trace metrics only.
"orders"
The event key to use in your code. Required for custom conversion/binary and custom numeric metrics only.
"Order placed"
Success criteria. Required for custom and trace numeric metrics, optional for custom and trace conversion metrics.
HigherThanBaseline, LowerThanBaseline "HigherThanBaseline"
Tags for the metric
Deprecated, use analysisUnits instead.
An array of analysis units allowed for this metric.
The ID of the member who maintains this metric
"569fdeadbeef1644facecafe"
The method by which multiple unit event values are aggregated
average, sum, count_distinct "average"
The method for analyzing metric events
"mean"
The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.
95
Filters for the metric to exclude certain events from being included. This is only supported for custom metrics.
Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
Lower winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, defines a two-sided clamp range. Otherwise lower-only winsorization.
1
Upper winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, must be greater than winsorLowerPercentile.
99.5
When true, the percentile bound calculation includes imputed zeros. Only meaningful when at least one bound is set and the metric includes units that didn't send events.
false
The trace query to use for the metric. Required for trace metrics.
"service.name = \"checkout\""
The location in the trace to use for numeric values. Required for numeric trace metrics.
"duration"
The warehouse column to use for counting distinct values. Required when the unitAggregationType is count_distinct.
For numeric warehouse-native metrics, the column holding the numeric value. Overrides the value column mapped on the data source.
For ratio metrics, the denominator event configuration. Only supported for warehouse native custom metrics.
Response
Metric response
The ID of this metric
"5902deadbeef667524a01290"
The version ID of the metric
"version-id-123abc"
A unique key to reference the metric
"metric-key-123abc"
A human-friendly name for the metric
"My metric"
The kind of event the metric tracks
pageview, click, custom, trace "custom"
The location and content type of related resources
Tags for the metric
Timestamp of when the metric was created
"1628192791148"
The number of experiments using this metric
0
The number of metric groups using this metric
0
The number of active experiments using this metric
2
The number of active guarded rollouts using this metric
1
Version of the metric
1
The number of feature flags currently attached to this metric
0
Details on how to access the metric in the LaunchDarkly UI
"{\"href\":\"/my-project/metrics/my-metric/details\",\"type\":\"text/html\"}"
Details on the allowed and denied actions for this metric
The ID of the member who maintains this metric
"569fdeadbeef1644facecafe"
Details on the member who maintains this metric
"{\"_links\":{\"self\":{\"href\":\"/api/v2/members/569fdeadbeef1644facecafe\",\"type\":\"application/json\"}},\"_id\":\"569fdeadbeef1644facecafe\",\"firstName\":\"Ariel\",\"lastName\":\"Flores\",\"role\":\"owner\",\"email\":\"ariel@acme.com\"}"
Description of the metric
The category of the metric
"Error monitoring"
For custom and trace metrics, whether to track numeric changes in value against a baseline (true) or to track a conversion when an end user takes an action (false).
true
For custom and trace metrics, the success criteria
HigherThanBaseline, LowerThanBaseline For numeric custom and trace metrics, the unit of measure
For custom metrics, the event key to use in your code
"Order placed"
Deprecated, use analysisUnits instead.
An array of analysis units allowed for this metric.
The filters narrowing down the audience based on context attributes or event properties.
"{\"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}]}"
The method by which multiple unit event values are aggregated
average, sum, count_distinct "average"
The method for analyzing metric events
mean, percentile "mean"
The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.
95
Timestamp of most recent data for this metric, at one-hour fidelity
Whether the metric version is archived
Timestamp when the metric version was archived
"1609459200000"
For click metrics, the CSS selectors
For click and pageview metrics, the target URLs
"[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]"
Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
Lower winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, defines a two-sided clamp range. Otherwise lower-only winsorization.
1
Upper winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, must be greater than winsorLowerPercentile.
99.5
When true, the percentile bound calculation includes imputed zeros. Only meaningful when at least one bound is set and the metric includes units that didn't send events.
false
For trace metrics, the trace query to use for the metric.
"service.name = \"checkout\""
For trace metrics, the location in the trace to use for numeric values.
"duration"
For count_distinct metrics, the column to count distinct values of
For ratio metrics, the denominator event configuration
Experiments that use this metric, including those using a metric group that contains this metric
Metric groups that use this metric
The most recent experiment that used this metric
The most recent guarded rollout that used this metric
Whether the metric is active
true
Details on the flags attached to this metric