Billing & Metering of app usage with Abacus


Hristo Iliev
 

We want to integrate the metrics provided by Cloud Foundry with Abacus
<https://github.com/cloudfoundry-incubator/cf-abacus>.

We plan to create a billing/metering integration layer that:

- fetches the app usage events
<http://apidocs.cloudfoundry.org/214/app_usage_events/list_all_app_usage_events.html>
from CC
- inserts runtime usage
<https://github.com/cloudfoundry-incubator/cf-abacus/blob/master/doc/api.md#runtime-usage>
data to Abacus

The events should be processed to build usage data based on them. This is
much like the idea outlined in Dr.Nic's blog
<https://blog.starkandwayne.com/2015/01/22/billing-your-cloud-foundry-users/>.
The integration layer can do this periodically.

AFAIK Abacus provides usage reports
<https://github.com/cloudfoundry-incubator/cf-abacus/blob/master/doc/api.md#usage-report>
for the current month only and not for arbitrary period of time. This
implies some restrictions to what we can report when the application is:

1. started and stopped several times in the month
2. started in the current month but not stopped at all
3. started in a previous month and not stopped

The first problem can be solved by iterating through the events and finding
the respective start and end timestamps that have to be reported to Abacus.

The second issue might be solved by reporting small amounts of usage,
stating from the last start event and continuing to report on every poll of
the integration layer. For example we can report several usages:

- start: 1438945112; end: 1438946000 (current time for the billing
integration)
- start: 1438946000 (previous reporting cycle); end: 1438947000

The third issue might be solved by finding the last start event and
reporting in the same manner as with #2.
Reporting usage in small steps might require persistence so we can store
the end time of the previous reporting. We might use in-memory cache and
reach to Abacus as primary storage. If Abacus can accumulate usage
reporting we can even get rid of the persistence and cache.

Is such integration in the scope of Abacus project?

Regards,
Hristo Iliev

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.