A billable metric tells Zenskar how to aggregate raw usage data into a single chargeable number for a billing period. For example, summing allDocumentation Index
Fetch the complete documentation index at: https://docs2.zenskar.com/llms.txt
Use this file to discover all available pages before exploring further.
cpu_hours_consumed events for a customer over a month produces the quantity that gets priced on their invoice.
In this step you will create two metrics:
- Total CPU Hours — sums CPU hours consumed per customer per month
- Total Storage GB-Months — sums storage consumed per customer per month
Prerequisites
Billable metrics
A billable metric aggregates usage event data over a billing period using functions like SUM, COUNT, or MAX. These metrics are the foundation for product pricing.
Define billable metrics
Navigate to Usage > Billable Metrics and click Add New Billable Metric. Choose your preferred method:- Visual Builder
- SQL Builder
The Visual Builder is a 4-step wizard. Complete it once for each metric.
Name the metric
Metric 1: Total CPU Hours
Select tables & filters
Under Table Name, select
compute_events — the usage event defined in step 2.1.Optionally, click + ADD FILTER to narrow events before aggregation (e.g., region = us-east-1).Map customer
- Your customer column:
customer_id— the field incompute_eventsthat identifies the customer. - Zenskar customer column:
external_id— links your system’s customer ID to the Zenskar customer record.
Metric 2: Total Storage GB-Months
Click Add New Billable Metric, select Visual Builder, and follow the same 4 steps with these values:| Step | Field | Value |
|---|---|---|
| Select tables & filters | Table Name | storage_events |
| Map customer | Your customer column | customer_id |
| Map customer | Zenskar customer column | external_id |
| Set date field | Column | timestamp |
| Set Billable Metric over | Calculation type | SUM |
| Set Billable Metric over | Column to calculate over | data.storage_gb_month |
Total Storage GB-Months and confirm.