Get the accounting parameters
The accounting parameters are stored in the accounting_parameters table in the kinton_accounting database.
See Abiquo accounting services integration for examples of basic queries to list and update the parameters.
Table of accounting parameters
Change the accounting period
To change the accounting period or other accounting parameters in an existing system, do these steps:
- Backup the accounting_event_detail table.
- Delete the existing content of the accounting_event_detail table.
- Change the accounting parameters to the desired values. Set MaximumPeriodsToFirstInit to ensure old data is accounted correctly.
- Monitor the content of accounting_event_detail to ensure the generated data meets your needs. If not, then repeat from step 2.
Set the account period size
The AccountPeriodSize parameter controls the minimum usage time of resources.
It sets the length of the accounting period. For each accounting period, the update procedure checks the Accounting event tables for resources that have been reserved and/or used in the last period by granularity and records the usage data in the accounting_event_detail table.
The minimum period of consumption of a resource is always one accounting period. If a resource is active for an interval of less than one accounting period, the system automatically rounds consumption up to one accounting period. But the value that accounting stores will depend on the granularity.
Users can turn resources on and off (again) during an accounting period. Abiquo stores all these events in the Accounting master tables. However, accounting_event_detail only contains the maximum value for an accounting period.
You can set the accounting period size parameter in the accounting_parameters table.
Parameter | Default value | Possible values | Description |
---|---|---|---|
AccountPeriodSize | HOUR | HOUR DAY WEEK MONTH | Controls the size of the aggregated account period of the accounting_event_detail table. If the value is bad or missing, the default value of 1 hour is used. |
For example, to change the accounting period to a day.
UPDATE accounting_parameters SET paramValue="DAY" WHERE paramName="AccountPeriodSize";
Set the granularity
For each accounting period, the Update procedure checks the master tables for resources reserved and/or consumed in the last period by granularity and records the usage data in the Accounting event detail table.
You can use the granularity to divide the value stored for each accounting period into smaller time units. However, the granularity does not affect the minimum usage.
The minimum period of usage is always determined by the accounting period:
- If accounting period = DAY and granularity = HOUR, then for a single CPU VM, Abiquo would record 24 resource units for a day record. So this could represent a charge for 24 hours of vCPU usage.
- If accounting period = DAY and granularity = DAY, then Abiquo will record 1 resource unit. So this could represent a charge for 1 day of vCPU usage.
You can set the granularity parameter in the accounting_parameters table.
Default value | Possible values | Description | |
---|---|---|---|
AccountPeriodGranularity | HOUR | HOUR DAY WEEK MONTH | Granularity of the resource units within an accounting period. If the value is bad or missing, the default value is used. The granularity must be smaller than the accounting period and the accounting period must be divisible by the granularity. |
The following table shows compatible periods and granularities. Abiquo uses calendar months, so week granularity is not compatible with month.
| Period | ||||
---|---|---|---|---|---|
Hour | Day | Week | Month | ||
Granularity
| Hour | ||||
Day |
| ||||
Week |
|
|
| ||
Month |
|
|
|
For example, to set the accounting period granularity to day.
We assume that the account period size is set to WEEK:
UPDATE accounting_parameters SET paramValue="DAY" WHERE paramName="AccountPeriodGranularity";
Check the updated value by using the select command.