Setting Budget and Alerts for your Google Cloud project

a.k.a. First thing you should do after registering to Google Cloud

Journey on Google Cloud for most people starts with registering, setting credit card info and then diving into Cloud Console to use awesome products and services. Google is gracious that it gives 300$ of credit for start, so you can freely explore and don’t worry that you will be billed from your own pocket from the first minute.

The first thing you should do however after getting to Cloud Console is to set Budget and Alerting rules and with this article I want to explain more why and how this is done.

There are Google Cloud users who set budget alerts and those who didn’t set yet

Billing is topic on it’s own and here I have in mind small to medium sized companies who are starting with Google Cloud and don’t have complex billing structure.

Why to set Budget and Alerts?

First of all it’s worth explaining what Budget is in the context of Google Cloud — it is amount of money of your current monthly bills based on which alert notifications can be triggered. It is NOT maximal amount you can be charged for using Google Cloud. If you go over budget, your running stuff on Google Cloud won’t be stopped, it will continue working and you will continue to be charged :)

Budgets should be considered something as soft limit for billing and in connection with alerts they can notify when certain percentage of budget amount is reached. Actual alert notifications are triggered based on percentual budget amount and are sent via email or they can publish messages to Pub/Sub topics as well.

Setting budget and alerts makes sense because:

  1. New users start to use Google Cloud spinning instances, clusters thinking that initial 300$ credit is sufficient but perhaps they forget to delete everything and next month they are surprised unpleasantly because of unexpected high billing amount.
  2. You can be notified if there are some unexpected costs, this can happen when you deploy new version of your code and due to some bug it can consume more resources than expected. Again you don’t have to wait until invoice to find out.
  3. You don’t go to Cloud Console often (thus you could check current cost) because your are not developer but rather manager and you have other things to do but in some way you are responsible for cloud bills.

In other words it’s a must to set Budget for your Billing account.

Next we’ll go trought process of setting budget and alert and see what kind of options there are.

Setting Budget and Alerts.

In order to use paid features of Google Cloud, you must link project to Billing Account (and create it if you don’t have any). Billing Account contains information like payment settings, reports, invoices etc.

To create Budget and Alerts to go to Billing Account detail. You can go to url https://console.cloud.google.com/billing or from Cloud Console menu link on Billing menu:

Google Cloud Billing

Then go to Budgets & Alerts sub menu to set those.

Google Cloud Billing

Then click on button to Create Budget

Creating Billing Budget

Next we have a form to create Budget together with Alerts.

Creating Budget
Creating budget and alerts

We’ll go through all fields:

Budget Name

Billing Account (to which budget is linked)

Budget Amount: There are 2 options to set amount. One is to simply specify fixed amount for your budget. Other option is to set budget amount based on “Last month’s spend” which will dynamically change every month. Of course this depends on the nature of your costs on Google Cloud. if you have relatively stable costs through the months, it can make sense to set based on “Last month’s spend”, since if you get alert for 50% reached budget in the middle of the month, that should mean that everything is ok. If you are doing creating / deleting lot of resources, trying out new things, than it makes more sense to set some fixed amount.

Cost after credit: If checked, this means that credit amount won’t be taken into account when alerting. For example, lets say you started using Google Cloud and you have 300$ of credits and set first alert for 10$. In case Cost after credit is checked, you will be notified after you spend 300$ of credit and 10$ of yours. If Cost after credit is not checked, you should be alerted when you spend first 10$ (from what ever source). I admit I’m not 100% sure if this is how it works, but based on description, it should.

Set alert threshold rules: You can specify multiple threshold rules based on budget percentage when notifications should be sent. Default value are 50%, 90% and 100%. For alert you can set either percent of budget or amount. Which ever field you enter, other one will be calculated. There is a choice to select Trigger and that can be either on Actual spent amount or based on Forecast. Triggering based on Forecast is a new feature and it sends alert when the spend is forecasted to exceed the percent of the budget amount by the end of the budget period.

Connect a Pub/Sub topic to this budget. When you check this option, you can select project and Pub/Sub topic to which alert will be published. Afterwards, you can connect Cloud Function which will be triggered by Pub/Sub and do something programatically there like for example stop some resources etc.

Budget period is always from beginning until the end of month.

This is how alert notification email looks like:

Budget alert
Alert notification email

I’m over my budget, now what?

It’s not the end of the world. Hopefully there is not much time lag between receiving alert and reading it, so you can react if necessary. Quickest way to diagnose unexpected costs it to go to Billing -> Reports in Cloud Console. There you have nice graph and list of most consuming resources with current monthly costs and predictions which should give you idea where potential problem is.

Billing Report

As old saying goes: “There are Google Cloud users who set budget alerts and those who didn’t set yet”