Chargeback is an important feature for computing infrastructures. Even inside an enterprise where IT users are not charged with real money, it’s still nice to see the usage patterns and sometimes avoid wasting resources. As I mentioned in IBM RC2, applying chargeback reduced unnecessary usage overnight.
VMware vCenter Chargeback is a component for this purpose. It can run standalone with Web GUI, and surface to vSphere Client as a plug-in. Although its name includes vCenter, it can also work with vCloud Director (see Using vCenter Chargeback with VMware Cloud Director).
Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.
I just spent some time over the weekend reading the API documentation, including vCenter Chargeback API Programming Guide, API Reference. The version 1.5 of the API covers Administration, Cost Management, Hierarchy Management, Report Management, User Management, Event Management, and Search. You can use API for pretty much everything you can do with the Chargeback GUI.
While reading the API docs, I found it’s not good idea to jump onto the API doc without knowing the key concepts used in the chargeback. This is a good example where you’d better know a product first before learning its APIs. Here is the User’s Guide you want to read in parallel and cross-reference.
Two key concepts that I think represent a little learning curve in the chargeback API are:
This is a tree structure that defines a scope for chargeback. It may or may not the same structure as vCenter inventory. I find the following description from User’s Guide very helpful.
A chargeback hierarchy is an organization of vCenter Server entities and vCenter chargeback entities. The vCenter Server entities include virtual machines, ESX Server hosts, data centers, resource pools, host folders, and virtual machine folders. A chargeback hierarchy can contain entities from more than one vCenter Server. The vCenter Chargeback entities are custom entities that could represent a logical parent for the vCenter Server entities. For example, the vCenter Chargeback entities could represent the departments, cost centers, or business units in an organization. A vCenter Chargeback entity can contain one or more vCenter Server entities and vCenter Chargeback entities.
These elements define the logic to calculate the cost to be charged. They include:
a. Chargeable computing resources: like CPU, memory, net bandwidth, storage, etc.
b. Base rate: a global rate that you charge for a unit of chargeable computing resource used, reserved, or allocated for a specific duration.
c. Fixed cost: a definite cost that can be charged on an entity. Fixed costs can be recurring costs or non-recurring or one-time costs.
d. Billing policy: determines the cost types and the amount of chargeable computing resources units to be considered for calculating the chargeback cost
e. Cost model: defines base rates for the chargeable computing resources, the currency, the billing policy to be used for calculating the total cost, and special costs, such as cost for the guest operating system installed on the virtual machine. A cost model also enables you to define different billing policies for different time periods.
Once you understand these concepts, others like user/role/report/event are straight-forward therefore not introduced here.
The REST API is very easy in the sense that it just CRUD (create, read, update, delete) these resources behind the key concepts. You can read the programming guide and API reference for more details.