Meters
Track, aggregate, and filter usage data
Meters define how events are aggregated and filtered. For example:
- A "calls" meter that counts the number of calls made by a user.
- A "messages" meter that sums the total number of messages sent by a user.
Meters can be attached to plan fees to form the basis of what's billed or attached to features to measure entitlement usage. Each meter can have multiple profiles, each with its own aggregation type and filtering criteria.
Meter profiles
Meter profiles allow you to define different ways to aggregate and filter the same event type in a single meter. For example, you might have a "local calls" meter profile that counts the number of local calls made by a user, and an "international calls" meter profile that counts the number of international calls made by a user. Each profile will have its own aggregation type and filtering criteria but will share the same event type from the meter.
Aggregation types
Billingrails allows various aggregations, making it suitable for a wide range of applications.
- Sum: The total sum of a numeric property associated with an event. For example, summing the total duration of calls.
- Count: The total number of occurrences of an event. For example, counting the number of messages sent.
- Count unique: The number of unique occurrences of an event based on a specific event property. For example, counting the number of unique users who sent messages.
- Max: The maximum value of a numeric property associated with an event. For example, finding the longest duration of a call.
- Min: The minimum value of a numeric property associated with an event. For example, finding the shortest duration of a call.
- Latest: The most recent value of a property associated with an event. For example, tracking the latest storage usage.
Filters
Meters can filter events based on their properties. This allows you to create more specific meters that only count certain types of events. For example, you might have a meter that only counts events where the country property is set to USA. Here's an example of a filter:
{
"value": "USA",
"operator": "in",
"property": ["country"],
}