Step 3: Define billable metrics
Zenskar's billable metrics allow you to aggregate and interpret the raw usage data collected from your client's system. This step involves defining how specific fields from your usage events (like cpu_hours_consumed or storage_gb_month) are aggregated over time to form billable quantities.
Prerequisites
Define billable metrics
The visual query builder provides a guided interface to define your billable metrics by selecting data tables and applying aggregation logic.
- Log in to your Zenskar dashboard.
- Navigate to Usage > Billable Metrics.
- Click ADD NEW BILLABLE METRIC and choose the VISUAL BUILDER option.
- Use the Visual Builder to create billable metrics:
First metric: For CPU usage
- Tab 1: Select tables and filters
- In the Select data table section, use the Table Name dropdown. Select
compute_events
(the usage event you defined in step 2.1 for CPU usage). - (Optional: Use + Add Filter if you need to filter events before aggregation, e.g., by
region
).
- In the Select data table section, use the Table Name dropdown. Select
- Tab 2: Map customer
- Click NEXT to proceed to the Map customer screen.
- Under Your customer column, select
customer_id
. This is the field from yourcompute_events
that identifies the customer in your system. - Under Zenskar customer column, select
external_id
. This maps ACME Inc.'s Id in your system to the Zenskar customer's unique external Id.
- Tab 3: Set date field
- Click NEXT to proceed to the "set date field" screen.
- Under "column", select
timestamp
. This maps the timestamp from yourcompute_events
as the primary date field for aggregation.
- Tab 4: Set billable metric over
- Click NEXT to proceed to the "set billable metric over" screen.
- Under Select calculation type, choose
SUM
(as opposed toCOUNT
) to sum up the values. - Under Select column to calculate over, choose
data.cpu_hours_consumed
. - Click CREATE BILLABLE METRIC. Give your metric a name (e.g.,
Total CPU Hours
).
Second metric: For storage usage
Repeat the process by clicking "add billable metric" and selecting "visual builder" again.
- Tab 1: Select tables and filters
- In the "select data table" section, choose
storage_events
(the usage event you defined in step 2.1 for storage usage). - Ensure the "usage event" checkbox is marked.
- In the "select data table" section, choose
- Tab 2: Map customer
- Map the
customer_id
field from yourstorage_events
to theexternal_id
in Zenskar.
- Map the
- Tab 3: Set date field
- Map the
timestamp
field from yourstorage_events
.
- Map the
- Tab 4: Set billable metric over
- Select calculation type: Choose
SUM
. - Select column to calculate over: Choose
data.storage_gb_month
. - Click CREATE BILLABLE METRIC. Give your metric a name (e.g.,
Total Storage GB-Months
).
- Select calculation type: Choose
Updated 25 days ago
What’s Next