Usage Metrics
A usage metric is a formula that aggregates a set of events into a single number representing total usage. To create a usage metric in the Sequence dashboard, click “Add new” and select “Usage metric”:

Give the metric a name and the type of usage events you want to aggregate – this should match the eventType in the usage event object. Then select how you want to aggregate the events; Sequence currently supports 3 aggregation types:
Aggregation type | Requires aggregation property | Description | SQL equivalent |
---|---|---|---|
COUNT | no | Total number of events | COUNT(*) |
SUM | yes | Sum of a numeric property | SUM(properties[‘property_name’]) |
UNIQUE | yes | Count of unique values of a property | COUNT(DISTINCT properties[‘property_name’]) |
SUM
and UNIQUE
require you to specify an event property as the argument of the aggregation, enter the name of this property in the “Aggregation property” field.
When the billing engine runs, it calculates all usage metrics for each of your customers over the last billing period. This calculated value is then combined with a price to determine the charge that will appear on the invoice.
Filtering
You can further refine the scope of a usage metric using filters. A filter limits the aggregation input to events that match a specific event property value. For example, if your events have a property called country, you can filter your metric to events where country = UK:

You can add more than one filter, in which case only events matching all filters will be included in the metric calculation.
Grouping
Use grouping to customize the layout of a usage-based charge on an invoice by breaking down usage by an event property. For example, grouping by country will let you display the usage for country = UK
and country = US
on separate lines on the invoice.
To learn more about customizing your invoice layout via grouping, reach out to the Sequence team.
Editing metrics
Updating and deleting usage metrics is currently only supported via the API. Making changes to a metric will not retroactively affect invoices already created. To update or correct existing invoices after changing a metric, recalculate a draft invoice, or issue a credit note against an issued invoice.