Skip to main content

Estimate and Monitor your cloud spend

Context

Nowadays, the cloud is used to reduce our total cost of ownership of our IS/IT assets. Transfering operational activities to cloud providers or transversal teams, or benefiting from dynamic sizing of the infrastructure resources. Rather than performing capacity planning, the challenge is nowadays to track costs and try to anticipate the cloud spent.

DBAAS provides a billing API that allows you to get insight on the pricing:

  • v2: you get the raw cloud consuption of k8saas per day, without the "added value" price of the trustnest platform

This API is exposed in our API portal: here

here

Use case

  • Get the price of the dbaas for a given day
  • Get data every day to monitor the trends
  • Get cost for a period of days to estimate his bill
  • Understand your trustnest billing

Known limitation

warning

The current (2023/01/27) billing API does not support yet dbaas/opensearch. Only cosmoDB and postgresql are supported for now. Opensearch will be supported during trustnest cycle 14 (Q1 2023).

What to do ?

First you need to know you TDFAccountID

Then, go to TrustNest K8SaaS Service catalog - General Inquiry asking to escalade the ticket to dbaas level 3 team, and providing the following information:

  • the TDFAccountID
  • the email address of the people who need access to the billing API
  • the instance name of dbaas you want to monitor

Once the configuration done, follow the steps:

Access to the queries using API Portal

Access to API portal using API Management portal. This portal shows all the transversal APIs that k8saas exposes. You should see Billing API v2 and Customer Apis. Billing v2 are restricted to trustnest billing Team. Only Customer Apis Access will be granted to you.

Sign in

Click on "sign in", then "Azure Active Directory". Indeed, the API Management portal is integrated with the Azure Active Directory of the platform where all the Thales employees are registered.

img

Access to the API

Once allowed on a specific product, you have access to all APIs inside, especially "Customer Apis". API Management portal provide a way to test the APIs using the button "Try it" in green.

tip

Tip: When you click on "Try it", by default it shows you HTTP request, but you have a menu to see other examples of code to query the API (Curl, Java, Python, Javascript etc...)

img

note

Note: Date format is: YYYY-MM-DD

Create your Product Subscription Key

You will need to create your own Subscription key to test and perform any request on the API. Click on "Products" at the top of the page. Click on "Billing v2". Enter your subscription name in the Box mention "Your new product subscription name" and click on the button "Subscribe". Your key will be generated and they must be validated by the MCS Team. Once allowed, you will have access to selected API.

img

Access to the queries using Curl

API portal provides a way to automate the monitoring of the costs:

export APIM_SUBSCRIPTION_KEY="xxxxx"
export BILLING_DATE="YYYY-MM-DD"
curl -X GET "https://dbaas-int-eu-prod-apim.azure-api.net/Consumer/billing/$BILLING_DATE" -H "Cache-Control: no-cache" -H "Ocp-Apim-Subscription-Key: $APIM_SUBSCRIPTION_KEY"

Supported request

https://dbaas-int-eu-prod-apim.azure-api.net/Consumer/billing/YYYY-MM-DD

Reserved instance (available soon)

It's possible to use Azure reserved instances feature to reduce your bill (available only in industrialize service offer). Please raise a postIT ticket to ask for it !

There are two types of reserved instance:

  • Reserved 1 year: Reserve one or several Azure machines for 1 year.
  • Reserved 3 years: Reserve one or several Azure machines for 3 years.

Of course, using of this option binds you with a 1 or 3 years contract. However the longer you commit yourself, the more money you save.

warning

If you reserved a machine for 1 or 3 years, you will pay for it even if you stop using it.

On the billing API response, there is a list of all reserved instances for each cluster, with the following fields:

"reserved_instances": [
{
"end_date": "2024-11-01T00:00:00Z",
"start_date": "2021-11-02T00:00:00Z",
"type": "RESERVED_INSTANCE_3_YEARS"
}
]

with for each reservation:

  • end_date: end date for the reservation instance
  • start_date: start date for the reservation instance
  • type: either "RESERVED_INSTANCE_1_YEAR" or "RESERVED_INSTANCE_3_YEARS"
tip

The reduction has been already applied to the billing api output, the information is only here to inform you on the active reservations.