Rivier/ Reference/ hosting

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

  • namestringrequired
    In the path

Request bodyapplication/json, required

  • labelstringrequired
    At most 120 characters.
  • descriptionstring
    What the figure means, in words a reader of a report understands Default: . At most 1000 characters.
  • sourceIdstring (uuid)required
    The linked database
  • tablestringrequired
    schema.table on the source's allow-list Pattern: ^[a-z_][a-z0-9_].[a-z_][a-z0-9_]$.
  • measureobjectrequired
    • fnstringrequired
      One of: count, count_distinct, sum, avg, min, max.
    • columnstring
      Pattern: ^[a-z_][a-z0-9_]{0,62}$.
  • wherelist of object
    Conditions that are part of the definition, such as status = paid Default: [].
    • columnstringrequired
      Pattern: ^[a-z_][a-z0-9_]{0,62}$.
    • opstring
      One of: eq, ne, lt, lte, gt, gte. Default: eq.
    • valuestring or numberrequired
  • dimensionslist of string
    Columns a reader may break the figure down by Default: [].
  • timeColumnstring
    The date or time column a period applies to Pattern: ^[a-z_][a-z0-9_]{0,62}$.
  • unitstring
    One of: count, currency, percent, duration, number. Default: number.
  • currencystring
    Pattern: ^[A-Z]{3}$.

Responses

  • 200application/json
    Success
    • 400application/json
      The request was malformed
      • errorstringrequired
      • messagestring
    • 401application/json
      No valid credential
      • errorstringrequired
      • messagestring
    • 403application/json
      The credential lacks the scope, origin or address
      • errorstringrequired
      • messagestring
    • 429application/json
      Over the key's rate limit; see Retry-After
      • errorstringrequired
      • messagestring

    This page as Markdown