How it fits together
- A virtual tag decides which subscription each charge belongs to. You write the rules; every value the tag produces is a Chargebee subscription id.
- A meter binds that tag key to one metered item price in your Chargebee account. Each night CostGraph records every customer’s attributed spend for each settled day against that item price.
- Chargebee prices and invoices. Metered items are charged in arrears, so the usage recorded during a term lands on that term’s invoice.
Subscriptions, not customers
Chargebee attaches usage to a subscription and an item price, not to a customer. That shapes both ends of the setup:- The tag values are subscription ids, so a customer with two subscriptions needs the tag to name whichever one should carry the cloud spend.
- The item price must belong to a metered item, and must already be part of that subscription - or have been part of it historically. CostGraph only offers item prices whose item is marked metered.
Connect
1
Create a metered item price
In Chargebee, create an item with metered enabled, give it a price, and
add that item price to the subscriptions you intend to bill.
2
Copy an API key
Open Settings -> Configure Chargebee -> API keys and copy a key.
3
Connect in CostGraph
Open Integrations, choose Chargebee, paste the key, and enter your
site name - the subdomain of your Chargebee site, so
acme-test for
acme-test.chargebee.com. CostGraph verifies the key against Chargebee
before saving anything, and stores it encrypted.4
Bind an item price
Bind a virtual tag key to one of your metered item prices.
Choose who gets billed
Create a virtual tag key named with achargebee_ prefix, such as
chargebee_subscription. The prefix is required: it marks the key as
billing-bound, and only prefixed keys can be bound to a meter.
The value a rule assigns is the subscription id the spend is recorded
against:
Any field works as the match: a linked account per customer, a resource name
prefix, a project, or an existing tag. See
Virtual tags for the rule builder and how
overlapping rules resolve.
Spend the tag does not match is never recorded.
Because a bound tag key drives invoices, CostGraph protects days that were
already recorded: rules on that key cannot be reordered, and new or edited
rules must start from a date that has not been recorded yet. Close an old rule
with an end date instead of editing it in place.
What lands in Chargebee
Chargebee keeps at most one usage record per subscription, item price and day. So unlike every other billing platform CostGraph exports to, it does not receive a stream of increments: each night CostGraph writes the day’s absolute total, replacing the record it wrote before. That makes corrections straightforward. A day revised downwards simply replaces the earlier record with the lower figure, as long as the term has not been invoiced yet, and no credit note is needed.Cloud providers restate recent spend, so CostGraph holds each day for two days
before recording it, then keeps reconciling the last 35 days. A day belonging
to a term that Chargebee has already invoiced can no longer be replaced, so
late restatements to a closed term need a manual adjustment in Chargebee.
Day to day
- The nightly run writes only what changed, so an unchanged day sends nothing.
- A day is held back rather than recorded wrong when its spend mixes currencies, or a quantity meter meets an unexpected unit. Each held day is recorded with its reason.
- Deactivating a meter stops recording but keeps its history, so reactivating resumes from what was already written instead of double-billing the window.
Next steps
Virtual tags
Write the rules that decide which subscription each charge belongs to.