Metering
Usage metering and report.
After the entitlement is created, you can report metric usage data to Suger in real time. Suger will aggregate the reported data by hourly and daily.
When the billing cycle is over, Suger will aggregate the total quantity of each billable dimension in this period, and calculate the amount of each billable dimension based on the aggregated data and the price model of the billable metric, the total amount will be used to generate the invoice.
Report usage to Suger
Use the following APIs to report usage data.
Request body example:
{
"ID": "request uuid", # Optional, if not provided, suger will generate one and return in the response.
"organizationID": "your-suger-org-id",
"entitlementID": "your-suger-entitlement-id",
"billableRecords": [
{
"key": "billable-metric-id-of-the-entitlment's-billable-dimension",
"properties": {
"custom-property-1": "val1",
"custom-property-2": "val2"
},
"quantity": 10, # The num of the metric.
},
...
]
}
- The organizationID and entitlementID are required. Each request can only report one entitlement's usage data.
- The billableRecords is an array, you can report multiple metrics in one request.
- The key is the billable metric id in the entitlement's billable dimension.
- The properties is a map of the custom properties of the billable metric, they are used for filter or group by or unique count.
- The quantity is the number of the metric.
The reported usage data can be viewed on the entitlement details page in real time.
Usage hourly report
Suger aggregates each entitlement's reported usage data every hour. It will help you to get a real-time view of the usage data.
- Every hour, Suger will aggregate the reported usage data of the previous hour.
- If the billable metric is configured with filters, the usage data will be filtered by the filters.
- After hourly aggregation is completed, it will generate the hourly report, and the original usage data will be marked as reported.
- Hourly reports only aggregate the quantity of metrics based on the metric's aggregation type, we will not calculate the corresponding amount because the price model need the total quantity of whole billing cycle.