Ends in
00
hrs
00
mins
00
secs
ENROLL NOW

▶️ 48-Hour Video Course Sale - Get Video Courses as LOW as $7.99 USD each only!

Cost Notifier: Keep Track of Your Google Cloud Platform Expenses

Home » BLOG » Cost Notifier: Keep Track of Your Google Cloud Platform Expenses

Cost Notifier: Keep Track of Your Google Cloud Platform Expenses

Have you ever had that moment when you realize your cloud costs have unexpectedly increased? Keeping track of your Google Cloud Platform (GCP) expenses usually requires manual effort, as you need to visit the console regularly. But what if you could receive daily updates on your costs automatically? Enter Slack notifications!

GCP Daily Cost Notifier

Imagine receiving a daily report about your GCP billing directly in your favorite messaging app. It’s like having a personal assistant to help you manage your cloud expenses. This automation uses BigQuery, Cloud Run Functions, and Cloud Scheduler to keep you informed about your costs. Let’s break it down step by step.

Tools and Technologies Used

Before we start, let’s overview the tools you’ll need:

  • Google Cloud Platform (GCP): Our main platform.

  • BigQuery: The database that stores our billing data.

  • Cloud Functions: To process the billing data and prepare it for notifications.

  • Cloud Scheduler: To trigger the Cloud Function daily.

Setting Up BigQuery Export

First, we need to export our billing data to BigQuery. Here’s how:

  1. Enable Billing Export to BigQuery: Go to your GCP console, navigate to the billing section, and enable the export option under Billing export. Choose the BigQuery dataset where you want the billing data to be stored. You can just use the Standard usage cost for the daily cost.

    Billing export

  2. Configure the Export: Set up the permissions and configurations to ensure data flows smoothly from your billing account to BigQuery.

  3. Tutorials dojo strip

Pricing Export

  • Once you activate the pricing export feature to BigQuery, it might take up to 48 hours for your Google Cloud pricing data to start appearing.
  • After activation, the pricing data for your Cloud Billing account is transferred to BigQuery once a day.

Creating a Cloud Run Function

Next, let’s create a Cloud Run Function that will process the billing data:

  1. Cloud Run Functions: Think of Cloud Run Functions as small pieces of code that run in the cloud, triggered by specific events.

  2. Create the Function: In the GCP console, go to Cloud Run Functions and create a new function. Choose the runtime environment that suits you (Node.js, Python, etc.).

  3. Write the Code: Your function will query BigQuery for the latest billing data, format the results, and send them to Slack. Here’s a simple code example to get you started:

This is primarily designed to track the total cost of your Google Cloud Platform (GCP) usage for the current month and send updates to a Slack channel. It uses Google BigQuery to query cost data and sends notifications through a Slack webhook. The script checks the current cost, updates it if there’s new data, and posts a message to Slack, ensuring you stay informed about your cloud expenses.

Scheduling the Cloud Function with Cloud Scheduler

To make sure our Cloud Function runs daily, we’ll use Cloud Scheduler:

  1. Cloud Scheduler: Cloud Scheduler is a fully managed cron service provided by Google Cloud Platform (GCP). It allows you to schedule and automate tasks, known as cron jobs, to run at specified times or regular intervals. These tasks can include batch jobs, big data jobs, cloud infrastructure operations, and more.

  2. Set Up the Scheduler: In the GCP console, navigate to Cloud Scheduler and create a new job. Set the frequency and point it to the Cloud Function you created. See the example configuration below:

    Cloud Scheduler

  3. Configuration: Ensure all the permissions and settings are correctly configured to allow the scheduler to trigger the function.

Testing and Troubleshooting

Before you relax, make sure everything works:

  1. Test the Setup: Open the URL of your Cloud Run Function and check Slack for the notification.

  2. Troubleshoot: If something goes wrong, check the logs in Cloud Functions and Cloud Scheduler for any errors.

Benefits and Use Cases

By setting up this automation, you’ll enjoy several benefits:

  • Stay Informed: Daily updates mean no more surprises at the end of the month.

  • Cost Management: Helps in better budget management and cost forecasting.

  • Ease of Access: Get all your billing updates in Slack, where you and your team already communicate.

Conclusion

With this automation, you’re well on your way to managing your GCP expenses. Daily Slack notifications will keep you informed and in control, all while simplifying your workflow. So, set it up, and let automation handle the rest.

Reference:

https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables

Tutorials Dojo portal

Level-Up Your Career this 2025

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Recent Posts

Written by: Nestor Mayagma Jr.

Nestor is a cloud engineer and member of the AWS Community Builder. He continuously strives to expand his knowledge and expertise in AWS to foster personal and professional growth. He also shares his insights with the community through numerous AWS blogs, highlighting his commitment to Cloud Computing technology. In his leisure time, he indulges in playing FPS and other online games.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?