Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs2.zenskar.com/llms.txt

Use this file to discover all available pages before exploring further.

A billable metric tells Zenskar how to aggregate raw usage data into a single chargeable number for a billing period. For example, summing all 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:
The Visual Builder is a 4-step wizard. Complete it once for each metric.

Metric 1: Total CPU Hours

1

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).
2

Map customer

  • Your customer column: customer_id — the field in compute_events that identifies the customer.
  • Zenskar customer column: external_id — links your system’s customer ID to the Zenskar customer record.
3

Set date field

Under Column, select timestamp. This scopes the aggregation to the billing period.
4

Set Billable Metric over

  • Select calculation type: SUM
  • Select column to calculate over: data.cpu_hours_consumed
Click create Billable Metric, name it Total CPU Hours, and confirm.

Metric 2: Total Storage GB-Months

Click Add New Billable Metric, select Visual Builder, and follow the same 4 steps with these values:
StepFieldValue
Select tables & filtersTable Namestorage_events
Map customerYour customer columncustomer_id
Map customerZenskar customer columnexternal_id
Set date fieldColumntimestamp
Set Billable Metric overCalculation typeSUM
Set Billable Metric overColumn to calculate overdata.storage_gb_month
Name the metric Total Storage GB-Months and confirm.