Skip to main content
An aggregation type defines how a billable metric calculates a quantity from usage events. Choose it based on what you want to measure: the number of actions, distinct users, a total, or a reported value. For example, use Count to count API calls, Sum to total tokens consumed, or Max to find the highest number of CPUs used. Count measures how many matching events Lago receives. Other aggregation types use a value within each event. Set field_name to the property you want to measure—for example, tokens to add up token usage. You can also use SQL expressions to calculate a value from event properties. The recurring setting controls what happens to the measured quantity when a billing cycle ends:
  • true: Lago keeps the quantity and carries it into the next billing cycle.
  • false: Lago resets the quantity, so each billing cycle starts fresh.

Aggregation examples

Compare how aggregation types calculate usage.

Metric recurrence

Choose whether aggregated values carry over or reset.

Create billable metrics

Define what to measure and how to calculate it.

Billable metric object (API)

Explore the metric’s fields.