No one likes to be surprised by a large expense. With cloud infrastructure, a simple mistake left unattended can result in an unexpectedly high bill. This is true of small $5 a month personal accounts and it is true of the largest accounts. You don’t want to wait until the invoice hits your inbox to know you have work to do, expectations to adjust, or justifications to make because the bill was larger than expected.
In this article we make use of the “Budgets and Alerts” function of Google Cloud Platform (GCP) billing console. We’ll configure it to give us weekly tracking against a budget, and we’ll have peace of mind that we aren’t going to be surprised by our cloud bill at the end of the month.
Budgets and Alerts
Tucked away into the GCP billing console is a useful function to alert you about your cloud spend. You can define a budgeted amount, and then the platform will alert you or trigger workflow whenever budgets exceed the defined threshold.
The budgets you define through this interface can be scoped to particular projects, labels*, or services (such as BigQuery or Compute Engine).
These budgets act as alerting thresholds only. They do not limit consumption.
Budgets are created through the Cloud Console, or via the CLI tool and APIs. The GCP Terraform provider1 has good coverage of this feature as well.
You have flexibility to carve up your budget by different scopes, or views, of your environment. You can managing budgets programmatically, and triggering alerts and workflows.
But for today, we’re going to configure a simple budget with scope of the entire billing account. You may get more advanced in your use of this feature as your cost management practices mature, but this configuration is recommended for all environments to provide early alerting of their cloud bill.
*Only resource labels are supported at this time. Project labels are not supported. This tool is not suited for defining budgets based on cost-center2.
Simple “Overall Budget” Objective
The budget we configure will be applied to 100% of resources within the billing account. To configure this budget you must have a perspective on what you expect to spend for a typical 31-day month. You may have a sophisticated way to derive this - or you may just use last month’s dollar amount and adjust based on expected changes. If it was a 30 day month, add 3%. Precision on this is not important, whatever you can pull together right now will serve our purpose.
This budget will alert at set thresholds: 23%, 46%, 69%, 92%, and 100%. These thresholds are important. They provide a way to break the month down into weeks, which allows for closer monitoring and earlier action if spend is exceeding budget. If your spend lines up with your projections, you will receive a budget alert on the 7th, 14th, 21st, and 28th days of the month. If you’re alerted earlier than the expected date, you will know you are spending your budget faster than expected, and will want to investigate the cause.
Browse to the GCP Billing Console and go to the Billing Account you wish to configure this budget for. Select “Budgets and Alerts”.
Here is where you will define a budget that will be used for alerting purposes.
Click “Create Budget” to create a new budget, and name it something like “Overall Budget”. Leave the Project, Product, and label configuration all at defaults.
Next, enter the dollar amount you expect your bill to reach at the end of the month. This will be pre-tax, so do not include any sales/use/tax in the dollar amount. For simplicity, allow the budget to be based on after-discounting prices - this is the default.
Finally, set thresholds at 23%, 46%, 49%, 92%, and 100%. As previously explained, these thresholds are important to get weekly perspective on budget consumption.
Example Email Notification
With the budget implemented as defined, all billing users and admins on the account will receive the following email notification when each threshold is reached.
If you’d like to narrow the recipient list of this email you may do so using the “Link Monitoring email notification channels to this budget” option on the budget configuration to link it to a Google Monitoring workspace notification channel.
Configuring this basic budget can give you a simple safety control to ensure costs aren’t growing unexpectedly. Using the thresholds given, you can get an early warning sign if costs are exceeding expectation. This is far better than waiting for the monthly invoice to come in. We recommend this practice regardless of the size and complexity of your environment. It can be used to augment more complex cost management and budget monitoring controls, as your environment requires.