One of the key benefits that the cloud brings to developers is the promise of reducing the cost of hosting applications. “Pay per use” is mentioned by every cloud vendor, but that by itself is not a magic wand by which the bills get reduced. A typical pattern is to observe monthly bills, see which services ended up being costly, then look at re-architecting bits and pieces of the application. Google Cloud Platform, which is fast becoming a strong alternative to Amazon Web Services, wants to make the task easier by providing a billing API that provides programmatic access to your daily Google Cloud Platform usage and cost estimates.
The Billing API works in conjunction with other Google Cloud Platform services, particularly Google Cloud Storage. All you need to do is enable the Billing Export feature from the Billing tab in the Google Cloud console. You can specify the bucket and a file prefix. A CSV or JSON file containing the usage and costs will be available on a 24-hour cycle.
The Compute Engine team is being very consistent in providing multiple ways to access this information. Like the other Google Cloud Platform services, you can access usage and cost information via the API, use a user interface (Cloud Console) to access the files or pull the information via the command line utilities. The official blog post presents sample billing data in JSON format, and absorbing this data into most programming environments today should be an uncomplicated process.
The Billing API is a welcome move that enables developers to access information that can help them understand and monitor their cloud usage costs. The graunularity of a 24-hour cycle makes it easier for developers to demand more frequent snapshots of their usage costs, define alerts with threshold values and much more. APIs are now available across the spectrum of Google Cloud Platform, and with the Billing API, developers can now create monitoring solutions that provide additional value to the standard tools provided by Google.