Monday, April 29, 2024
No menu items!
HomeCloud ComputingUsing Google Cloud’s new Pricing API

Using Google Cloud’s new Pricing API

If you are an existing Google Cloud user, you might already be familiar with the Billing Catalog API, which provides programmatic access to list prices for all public services and SKUs in billing. A service groups together SKUs of the same product line. Recently, Google Cloud released a new Pricing API that is an improvement over the existing Catalog API. The new Pricing API is available  in public preview and open to all customers. 

The new Pricing API allows you to not only get list prices on all the available services but also account-specific custom prices and discounts with additional metadata, down to the SKU level. Visibility into your custom pricing and discounts along with SKU-level metadata, including product and geo taxonomy, allows this API to efficiently facilitate improved cost auditing, estimation, and spend optimization.

Why does pricing matter?

Every organization in the cloud wants to optimize costs. However, it can be  difficult to assess current costs or estimate future trends without understanding prices. The price of a SKU is calculated using a pricing model that takes into consideration the list price of that SKU, account-specific discounts, and accrued usage in the past. Different services and SKUs employ different pricing models. Depending on your negotiated contract or agreement, your account may have varied types of discounts. Additionally, foreign exchange rates may also play a role in determining the price in your local currency. Given all these variables, understanding price is not straightforward. However, knowing the exact price specific to your account is important to support your cost optimization goals, with Pricing API’s intent being to help you in this journey! 

How is the new Pricing API different from the existing Billing Catalog API?

For starters, the Catalog API only provides an inventory of public services and SKUs with their list prices. The Pricing API, on the other hand, gives you visibility into all public services and SKUs plus the ones that are available to your billing account as part of your contract or agreement. What specifically differentiates it from the Catalog API is that it shows your negotiated contract pricing and discounts, if any, for all the SKUs, specific to your account. In addition to metadata such as SKU-to-service mapping that is already provided by the Catalog API, it provides additional information such as list of SKU groups, SKU-to-SKU group mapping, and geo and product taxonomy that allows you to further slice and dice the SKUs for improved analysis.  

The release of the Pricing API opens up multiple possibilities for pricing and cost analysis. As similar types of resources are priced differently across regions, this API allows you to track and compare your prices to determine the ideal SKU for cost optimization. It also allows you to track your custom discounts across resources and regions to understand how your savings compare. Further, you can also use this API, along with usage metrics, to analyze any spikes indicated in your cost reports. For instance, assume your reports showed a cost increase for one of the services used by your account, say Cloud SQL. In addition to analyzing your usage of this service, you could filter and drill into the SKUs that belong to this specific service by using the Pricing API’s ListBillingAccountSkus method. Your query and JSON response, for this example, would look something like the below. Please note these are sample responses for illustrative purposes.

code_block[StructValue([(u’code’, u’GET https://cloudbilling.googleapis.com/v1beta/billingAccounts/00A546-D8817D-85AAE7/skus?pageSize=2&filter=billing_account_service=”billingAccounts/00A546-D8817D-85AAE7/services/9662-B51E-5089″‘), (u’language’, u”), (u’caption’, <wagtail.wagtailcore.rich_text.RichText object at 0x3e2fc693ea10>)])]
code_block[StructValue([(u’code’, u'{rn “billingAccountSkus”: [rn {rn “name”: “billingAccounts/00A546-D8817D-85AAE7/skus/000E-8560-3D8D”,rn “skuId”: “000E-8560-3D8D”,rn “displayName”: “Cloud SQL for MySQL: Zonal – 96 vCPU + 360GB RAM in Paris”,rn “billingAccountService”: “billingAccounts/00A546-D8817D-85AAE7/services/9662-B51E-5089”,rn “productTaxonomy”: {rn “taxonomyCategories”: [rn {rn “category”: “GCP”rn },rn {rn “category”: “Databases”rn },rn {rn “category”: “Cloud SQL”rn },rn {rn “category”: “MySQL”rn },rn {rn “category”: “Compute”rn },rn {rn “category”: “Cores: 65 to 96″rn }rn ]rn },rn “geoTaxonomy”: {rn “type”: “TYPE_REGIONAL”,rn “regionalMetadata”: {rn “region”: {rn “region”: “europe-west9″rn }rn }rn }rn },rn {rn “name”: “billingAccounts/00A546-D8817D-85AAE7/skus/002C-0797-D407”,rn “skuId”: “002C-0797-D407”,rn “displayName”: “Cloud SQL for PostgreSQL: Regional – IP address reservation in Salt Lake City””,rn “billingAccountService”: “billingAccounts/00A546-D8817D-85AAE7/services/9662-B51E-5089”,rn “productTaxonomy”: {rn “taxonomyCategories”: [rn {rn “category”: “GCP”rn },rn {rn “category”: “Databases”rn },rn {rn “category”: “Cloud SQL”rn },rn {rn “category”: “Postgres”rn },rn {rn “category”: “IP Charges”rn }rn ]rn },rn “geoTaxonomy”: {rn “type”: “TYPE_REGIONAL”,rn “regionalMetadata”: {rn “region”: {rn “region”: “us-west3″rn }rn }rn }rn }rn ],rn “nextPageToken”: “ChRyEgoQQg4wMDI1LTRCRkYtNTc0OBIMCIfesqUGEIDhycMD”rn}’), (u’language’, u”), (u’caption’, <wagtail.wagtailcore.rich_text.RichText object at 0x3e2fc693e210>)])]

Note that the response to the above query has been limited to two SKUs for the purposes of this example. 

You can further drill into any of the SKUs to understand the exact contracted price and discount, using the GetBillingAccountPrice method. Your query and response for this specific example would look something like this:

code_block[StructValue([(u’code’, u’GET https://cloudbilling.googleapis.com/v1beta/billingAccounts/00A546-D8817D-85AAE7/skus/000E-8560-3D8D/price’), (u’language’, u”), (u’caption’, <wagtail.wagtailcore.rich_text.RichText object at 0x3e2fc693e650>)])]
code_block[StructValue([(u’code’, u'{rn “name”: “billingAccounts/00A546-D8817D-85AAE7/skus/000E-8560-3D8D/price”,rn “currencyCode”: “USD”,rn “valueType”: “rate”,rn “rate”: {rn “tiers”: [rn {rn “startAmount”: {rn “value”: “0”rn },rn “listPrice”: {rn “currencyCode”: “USD”,rn “units”: “7”,rn “nanos”: 523600000rn },rn “contractPrice”: {rn “currencyCode”: “USD”,rn “units”: “4”,rn “nanos”: 514160000rn }rn }rn ],rn “unitInfo”: {rn “unit”: “h”,rn “unitDescription”: “hour”,rn “unitQuantity”: {rn “value”: “1”rn }rn },rn “aggregationInfo”: {rn “level”: “LEVEL_ACCOUNT”,rn “interval”: “INTERVAL_MONTHLY”rn }rn },rn “priceReason”: {rn “type”: “floating-discount”,rn “floatingDiscount”: {rn “discountPercent”: {rn “value”: “40”rn },rn “discountScopeType”: “sku-group”,rn “skuGroup”: “c26b6763-7eb6-4167-bc30-594e8f4d0bfe”rn }rn }rn}’), (u’language’, u”), (u’caption’, <wagtail.wagtailcore.rich_text.RichText object at 0x3e2fc693e390>)])]
code_block[StructValue([(u’code’, u’u200bu200bGET https://cloudbilling.googleapis.com/v1beta/billingAccounts/00A546-D8817D-85AAE7/skus/002C-0797-D407/price’), (u’language’, u”), (u’caption’, <wagtail.wagtailcore.rich_text.RichText object at 0x3e2fc693e5d0>)])]
code_block[StructValue([(u’code’, u'{rn “name”: “billingAccounts/00A546-D8817D-85AAE7/skus/002C-0797-D407/price”,rn “currencyCode”: “USD”,rn “valueType”: “rate”,rn “rate”: {rn “tiers”: [rn {rn “startAmount”: {rn “value”: “0”rn },rn “listPrice”: {rn “currencyCode”: “USD”,rn “nanos”: 12000000rn },rn “contractPrice”: {rn “currencyCode”: “USD”,rn “nanos”: 7200000rn }rn }rn ],rn “unitInfo”: {rn “unit”: “h”,rn “unitDescription”: “hour”,rn “unitQuantity”: {rn “value”: “1”rn }rn },rn “aggregationInfo”: {rn “level”: “LEVEL_ACCOUNT”,rn “interval”: “INTERVAL_MONTHLY”rn }rn },rn “priceReason”: {rn “type”: “floating-discount”,rn “floatingDiscount”: {rn “discountPercent”: {rn “value”: “40”rn },rn “discountScopeType”: “sku-group”,rn “skuGroup”: “c26b6763-7eb6-4167-bc30-594e8f4d0bfe”rn }rn }rn}’), (u’language’, u”), (u’caption’, <wagtail.wagtailcore.rich_text.RichText object at 0x3e2fc693ea50>)])]

Based on the above response, you can see that the SKU for ‘Cloud SQL for PostgreSQL’ in the us-west3 region is slightly cheaper than the other SKU. However, they both get the same type of discount, related to SKU group, and in this case they both belong to the same SKU Group. From here, you could drill into the specific SKU Group, using ListSkuGroupSkus method, to understand if there are other SKUs that align with your usage needs and are better positioned to bring your costs down. 

What the Pricing API effectively does is enable you to build applications on top of it that compare different SKUs on varied parameters, including price, to aid your usage and cost analyses. Additional uses include support in helping determine your budgets, and efficient auditing of your payments and invoices. Like I said, the possibilities for analysis using this API are endless!

How to get started

To understand more about the Pricing API and to get started, check out the documentation here. It gives a detailed description of all the API calls, sample responses, resources and permissions you need to access desired information. To stay on top of what’s new with Google Cloud billing, head over to Cloud Billing Release Notes

Additionally, if you are planning to attend Google Cloud Next, be sure to stop by the following FinOps and cost optimization sessions:

Unlock Cloud value for everyone using Google Cloud FinOps tools

Control cost and build financial resilience with automation: An SAP story

Use Looker to empower Cloud financial decisions and FinOps

Optimize your Google Cloud costs with data-driven approaches

Optimize your data and analytics costs

Create a FinOps culture change through automation

Cloud BlogRead More

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments