Write a metric once
put/datasources/metrics/{name}
Write a metric once: what is counted (count, sum, average...), from which allowed table, with which conditions, by which dimensions and time column. A change makes a new draft; the approved version stays in use until a person approves the new one. The definition is tried over the whole table before it is kept.
Before you call
- Credential
Authorization: Bearer $KEY- Scope
hosting:write- Graphql
Mutation.hostingMetricDraft- Sdk
hosting.metric.draft- Cli
hosting metric draft
Parameters
- namestringrequiredIn the path
Request bodyapplication/json, required
- labelstringrequiredAt most 120 characters.
- descriptionstringWhat the figure means, in words a reader of a report understands Default: . At most 1000 characters.
- sourceIdstring (uuid)requiredThe linked database
- tablestringrequiredschema.table on the source's allow-list Pattern: ^[a-z_][a-z0-9_].[a-z_][a-z0-9_]$.
- measureobjectrequired
- fnstringrequiredOne of: count, count_distinct, sum, avg, min, max.
- columnstringPattern: ^[a-z_][a-z0-9_]{0,62}$.
- fnstringrequired
- wherelist of objectConditions that are part of the definition, such as status = paid Default: [].
- columnstringrequiredPattern: ^[a-z_][a-z0-9_]{0,62}$.
- opstringOne of: eq, ne, lt, lte, gt, gte. Default: eq.
- valuestring or numberrequired
- columnstringrequired
- dimensionslist of stringColumns a reader may break the figure down by Default: [].
- timeColumnstringThe date or time column a period applies to Pattern: ^[a-z_][a-z0-9_]{0,62}$.
- unitstringOne of: count, currency, percent, duration, number. Default: number.
- currencystringPattern: ^[A-Z]{3}$.
Responses
- 200application/jsonSuccess
- 400application/jsonThe request was malformed
- errorstringrequired
- messagestring
- 401application/jsonNo valid credential
- errorstringrequired
- messagestring
- 403application/jsonThe credential lacks the scope, origin or address
- errorstringrequired
- messagestring
- 429application/jsonOver the key's rate limit; see Retry-After
- errorstringrequired
- messagestring