How metered billing works
A meter defines one thing you measure, such as API calls, gigabytes stored or active users, and how a period's events turn into a single number. Your application sends an event whenever usage happens, tagged with the customer and a quantity.
At the end of the period the meter aggregates the events. The common aggregations are sum, which adds up every quantity; count, which counts the events and ignores their quantity; max, the highest value seen, for peaks like concurrent users; and last, the most recent value, for a gauge like seats in use at the end of the cycle. The result then goes through the price on the customer's subscription.
The aggregation changes the bill, so it is fixed when the meter is created. Switching it partway through would make old and new periods disagree.
Worked example
You meter API calls and charge $0.01 per call. In one period a customer's app sends three events: 100 calls, 250 calls and 80 calls.
- Sum of quantities: 100 + 250 + 80
- 430 calls
- Count of events
- 3 events
- Charge with a sum meter: 430 × $0.01
- $4.30
With a count meter the same period would bill 3 × $0.01 = $0.03, which is why the aggregation has to match what each event means.
Why metering matters
Metering is what makes a usage charge believable. A customer who questions a usage line wants to see the events behind it, and you want one source of truth for how the number was reached.
It also separates measuring from pricing. The meter records what happened; the price decides what it costs. You can change prices, add tiers or run a promotion without touching how usage is recorded.
Common mistakes
- Sending running totals to a sum meter If each event carries the total so far, summing them counts the same usage many times. Send increments to a sum meter, or send the current total to a last meter.
- No rule for late events Usage that arrives after the period closes needs a rule: bill it next period or reject it. Decide before it happens.
- Duplicate events Networks retry. Give each event a unique key so a retry is not billed twice.