What is usage metering?
Aggregation Type | Description | Example Use case |
---|---|---|
COUNT | Counts the number of times an incoming events occurs, matching it’s conditions. Togai will compute the number of events within the given time interval. | Number of transactions (payment gateways), Number of chat requests for a chatbot |
SUM | Adds a defined property of incoming events. Togai will compute the total of all values reported within a selected time. | Total amount of money processed by payment gateways, Total GB-min for cloud infra provider |
MAX | Provides the maximum value of the chosen series of data points | Peak load experienced in a day |
MIN | Provides the minimum value of the chosen series of data points | Lowest number of concurrent users |
AVERAGE | Computes the average of the data points during a particular time window | Daily average of transaction volume |
DISTINCT COUNT | Computes the number of unique values amongst a stream of data grouped by a chosen dimension | Monthly active users |
2.9% + 30¢
per successful card charge.
To model this 2-part pricing of Stripe, you’ll need to create two usage meters. The event schema to be associated to both the usage meters will look like this:
**2.9% of transaction amount**
.
In this case, we need to sum the total transaction amount across various transactions for a particular user and then calculate 2.9% of that.
Clearly, this requires us to use the sum function and so we set the aggregation type to Sum
.
Payment Mode
as a filter condition.
**30¢ per transaction**
.
In this case, for every unique transaction done by a user we need to increase the counter by 1. So that we can then multiply the final number of the counter with 30 (cents).
This requires us to use the count function and so we set the aggregation type to Count
.