Skip to content
LogoLogo

Metric schema

See Management API schema for every domain, the endpoint and authentication.

Types

MetricTimeUnit

"""
A unit of calendar time: a window's length, or a timeseries bucket's width.
"""
enum MetricTimeUnit {
  """One hour."""
  HOUR
  """One day, from local midnight."""
  DAY
  """One week, from Monday at local midnight."""
  WEEK
  """One calendar month, from the first at local midnight."""
  MONTH
}

MetricDurationInput

"""A length of time as a whole number of units."""
input MetricDurationInput {
  """The number of units. At least 1."""
  amount: Int!
  """The unit."""
  unit: MetricTimeUnit!
}

MetricDateRangeInput

"""Whole calendar days, both ends inclusive."""
input MetricDateRangeInput {
  """The first day."""
  start: IsoDate!
  """The last day, included."""
  end: IsoDate!
}

MetricWindowInput

"""
The span of time a metric covers. Give exactly one of `last`, `dates`, or
both `from` and `to`.
 
`last` ends with the current unit and covers the `amount - 1` units before it,
with unit boundaries in `timezone`: `{ amount: 7, unit: DAY }` is today and
the six days before it. Two requests within the same unit resolve to the same
window.
"""
input MetricWindowInput {
  """A relative window ending with the current unit."""
  last: MetricDurationInput
  """
  Whole days, from local midnight on `start` to local midnight after `end`.
  """
  dates: MetricDateRangeInput
  """Start of an absolute window, inclusive."""
  from: DateTime
  """End of an absolute window, exclusive."""
  to: DateTime
  """
  IANA time zone that unit and bucket boundaries align to. Defaults to the project's `timezone`.
  """
  timezone: String
}

MetricWindow

"""The span of time a metric covered, after its window was resolved."""
type MetricWindow {
  """Start of the window, inclusive."""
  from: DateTime!
  """End of the window, exclusive."""
  to: DateTime!
  """The IANA time zone unit and bucket boundaries align to."""
  timezone: String!
}

Metric

"""
Something countable over time, read as a total or as a timeseries.
 
`window` defaults to the window of the resource the metric hangs off, such
as the `window` given to `Project.leads`; a metric with neither fails. A
measurement that would read too much data, or for too long, fails with an
error rather than returning a partial value.
"""
interface Metric {
  """
  The metric over a window, split by the metric's group-by when it has one.
  """
  total(window: MetricWindowInput): MetricTotal!
  """
  The metric over a window, in buckets of `interval`. At most 745 buckets.
  """
  timeseries(window: MetricWindowInput, interval: MetricTimeUnit!): Timeseries!
}

CountMetric

"""A plain count, such as leads captured or sessions started."""
type CountMetric implements Metric {
  """
  The count over a window, split by the metric's group-by when it has one.
  """
  total(window: MetricWindowInput): MetricTotal!
  """
  The count over a window, in buckets of `interval`. At most 745 buckets.
  """
  timeseries(window: MetricWindowInput, interval: MetricTimeUnit!): Timeseries!
}

MetricTotal

"""A metric's value over one window."""
type MetricTotal {
  """The window that was counted."""
  window: MetricWindow!
  """The value over the whole window."""
  value: Float!
  """
  The value per group, largest first, when the metric has a group-by; empty
  otherwise. At most 10 groups; the rest fold into one group whose `key` is null.
  """
  groups: [MetricGroupValue!]!
  """Whether the values are estimates rather than exact counts."""
  approximate: Boolean!
  """The newest data the values reflect."""
  freshAsOf: DateTime!
}

MetricGroupValue

"""One group's share of a metric total."""
type MetricGroupValue {
  """
  The group-by value, or null for the group folding every group past the cap.
  """
  key: String
  """A human-readable name for the group."""
  label: String!
  """The group's value."""
  value: Float!
}

Timeseries

"""
A metric bucketed over time, column by column. `buckets` is the time axis
every series shares, and each series carries one value per bucket, so
`series[i].values[j]` is the value of series `i` in the bucket starting at
`buckets[j]`.
"""
type Timeseries {
  """The window that was counted."""
  window: MetricWindow!
  """The width of each bucket."""
  interval: MetricTimeUnit!
  """
  The start of each bucket, oldest first. Every bucket is present; an empty one counts 0.
  """
  buckets: [DateTime!]!
  """
  The series, largest first. One series with a null `key` when the metric has
  no group-by. At most 10 series; the groups past the cap fold into one series
  whose `key` is null.
  """
  series: [TimeseriesSeries!]!
  """Whether the values are estimates rather than exact counts."""
  approximate: Boolean!
  """The newest data the values reflect."""
  freshAsOf: DateTime!
}

TimeseriesSeries

"""One line of a timeseries."""
type TimeseriesSeries {
  """
  The group-by value; null for the folded "Other" series and for the single series of an ungrouped metric.
  """
  key: String
  """A human-readable name for the series."""
  label: String!
  """One value per bucket, aligned with `Timeseries.buckets`."""
  values: [Float!]!
}