Creates a metered feature.
Use query to define how Chargebee measures usage for the metered feature. The result is a single aggregate across all matching usage events. To report grouped usage, include attributes in a GROUP BY clause. Each distinct set of values forms one usage group. These attributes are the metered feature's group-by attributes.
Availability
Support for adding GROUP BY to metered features and retrieving usage grouped by attributes is an upcoming capability and is not generally available yet. It will be made available in the coming weeks.
Use Cases
Sample Request
Sample Result[JSON]
URL Format
Input Parameters
The SQL query used to calculate usage from usage_event properties. For example: SELECT SUM(api_calls) FROM events WHERE status = 'completed'.
To group usage by attribute values, include a GROUP BY clause. Each distinct set of group-by attribute values forms a separate usage group. For example: SELECT SUM(hours) FROM events WHERE status = 'completed' GROUP BY gpu_type, region. The response returns the group-by attribute names in group_by, in the same order.
Availability
Support for adding GROUP BY to metered features and retrieving usage grouped by attributes is an upcoming capability and is not generally available yet. It will be made available in the coming weeks.
Constraints
- Properties used in the aggregate expression or
WHEREclause must be listed incolumn_definitions.column_name. - A group-by attribute used only in the
GROUP BYclause does not require acolumn_definitionsentry. Its value is treated as a string. - The
GROUP BYclause can contain up to 5 group-by attributes. - Exact duplicate group-by attribute names are not allowed. Names are case-sensitive, so
region, regionis invalid, whileregion, Regionidentifies two different attributes.
Usage reporting and subscription billing
For a metered feature whose query includes a GROUP BY clause, grouped usage is available in Retrieve usage summary for a subscription and Retrieve usages for an invoice as PDF. These groups are for reporting only. Subscription billing uses the overall aggregate for the metered feature and does not bill each group separately.
For example, a SUM query can return 60 hours for region=us-east and 40 hours for region=eu-west. The reporting operations can display both groups. Subscription billing uses the overall aggregate of 100 hours.
Returns
Resource object representing the meter for the metered feature.