This is just a sample of the message with a subset of properties
Here’s the full notification format if you want to see more, but we’re primarily going to focus on a few key properties.
costAmount
is the current cost against that budget, for whatever filters you chose (such as just Compute Engine products, or just your dev initiatives)budgetAmount
is the amount you’ve configured for the budget, andbudgetAmountType
will beSPECIFIED_AMOUNT
orLAST_MONTH_COST
relying on how you set the budget upcostIntervalStart
is the start of the current time period where costs are being measured, which will be the start of the monthalertThresholdExceeded
is the last threshold that has been passed based on the ones you’ve set up. If you want a refresher on thresholds, check out the first postbudgetDisplayName
is the name of the budget, but you can actually get the unique ID of the budget through some extra metadata (that we’ll approach back to later)
So with these basic properties, we get a lot of information about the budget! On top of that, we’ll get this notification multiple times a day (last time I checked I got it over 40 times scattered throughout a day) so we’ll always get pretty up-to-date information.
Note: Even though the notifications approach in pretty consistently, cost data can nonetheless take some time to be reported from the resource level. The budget information will be up to date with the best information it has, but plan accordingly.
Another necessary note is that this notification doesn’t intrude with your threshold alerts. You can hold all of those the same and you’ll nonetheless get your alerts in the same way, plus these notifications will be sent to your Pub/Sub topic.
Well that’s fine and dandy, but now we need to actually do something with the notification. So, let’s use the lightweight Cloud Functions to be a subscriber of our topic.
Cloud Functions saves the day
Use the left-nav to head to find Cloud Functions and head there.