Bird
Raised Fist0
GCPcloud~10 mins

Cost management with billing reports in GCP - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable billing export to BigQuery.

GCP
gcloud beta billing export bigquery set --billing-account [1] --dataset my_billing_dataset
Drag options to blanks, or click blank then click option'
Abilling-export
Bmy-project-id
C012345-6789AB-CDEF01
Dmy-billing-account
Attempts:
3 left
💡 Hint
Common Mistakes
Using the project ID instead of the billing account ID
Using the dataset name as billing account
2fill in blank
medium

Complete the code to create a BigQuery dataset for billing export.

GCP
bq mk --dataset [1]:my_billing_dataset
Drag options to blanks, or click blank then click option'
Abilling-dataset
Bmy-project-id
Cbilling-account
Dbilling-project
Attempts:
3 left
💡 Hint
Common Mistakes
Using billing account ID instead of project ID
Using dataset name as project ID
3fill in blank
hard

Fix the error in the SQL query to calculate total cost per service.

GCP
SELECT service.description, SUM(cost) AS total_cost FROM `[1].gcp_billing_export_v1_0123456789ABCDEF` GROUP BY service.description
Drag options to blanks, or click blank then click option'
Amy-project-id.billing
Bbilling-project.billing
Cbilling-account.billing
Dmy-project-id.my_billing_dataset
Attempts:
3 left
💡 Hint
Common Mistakes
Using billing account ID as dataset
Using incorrect dataset name with dots
4fill in blank
hard

Fill both blanks to filter billing data for the last 30 days and group by project.

GCP
SELECT project.id, SUM(cost) AS total_cost FROM `[1].my_billing_dataset.[2]` WHERE usage_start_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY) GROUP BY project.id
Drag options to blanks, or click blank then click option'
Amy-project-id
Bgcp_billing_export_v1_0123456789ABCDEF
Cbilling_dataset
Dbilling_export
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping project ID and dataset name
Using incorrect table name
5fill in blank
hard

Fill all three blanks to create a billing alert policy using gcloud CLI.

GCP
gcloud alpha billing budgets create --billing-account=[1] --display-name=[2] --amount=[3]
Drag options to blanks, or click blank then click option'
A012345-6789AB-CDEF01
B"Monthly Budget Alert"
C1000
Dmy-budget
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the display name
Using project ID instead of billing account
Using string instead of number for amount

Practice

(1/5)
1. What is the main purpose of billing reports in Google Cloud Platform?
easy
A. To monitor network traffic between services
B. To deploy new cloud resources automatically
C. To manage user permissions and roles
D. To track and understand cloud costs over time

Solution

  1. Step 1: Understand billing reports function

    Billing reports show how much you spend on cloud resources over time.
  2. Step 2: Identify the correct purpose

    Tracking and understanding costs helps manage budgets effectively.
  3. Final Answer:

    To track and understand cloud costs over time -> Option D
  4. Quick Check:

    Billing reports = track costs [OK]
Hint: Billing reports show cost details, not deployments or permissions [OK]
Common Mistakes:
  • Confusing billing reports with deployment tools
  • Thinking billing reports manage user roles
  • Assuming billing reports monitor network traffic
2. Which gcloud command lists billing accounts available to your user?
easy
A. gcloud iam roles describe
B. gcloud billing accounts list
C. gcloud projects create
D. gcloud compute instances list

Solution

  1. Step 1: Identify command for billing accounts

    The command to list billing accounts is 'gcloud billing accounts list'.
  2. Step 2: Eliminate unrelated commands

    Other commands manage compute, projects, or IAM roles, not billing accounts.
  3. Final Answer:

    gcloud billing accounts list -> Option B
  4. Quick Check:

    List billing accounts = gcloud billing accounts list [OK]
Hint: Billing commands start with 'gcloud billing' [OK]
Common Mistakes:
  • Using compute or IAM commands to list billing accounts
  • Confusing project creation with billing listing
  • Typing incorrect command syntax
3. Given this snippet of a billing report summary:
Project: my-project
Cost: $120.50
Month: April

What does this report tell you?
medium
A. The project budget is $120.50 for April
B. The project has $120.50 remaining in April
C. The project spent $120.50 in April
D. The project was created in April

Solution

  1. Step 1: Read the billing report details

    The report shows cost as $120.50 for the project in April.
  2. Step 2: Understand cost vs budget

    Cost means money spent, not budget or remaining funds.
  3. Final Answer:

    The project spent $120.50 in April -> Option C
  4. Quick Check:

    Cost = money spent [OK]
Hint: Cost means money spent, not budget or leftover [OK]
Common Mistakes:
  • Confusing cost with budget or remaining funds
  • Assuming project creation date from cost report
  • Misreading the month field
4. You tried to generate a billing report but got an error: Permission denied. What is the most likely cause?
medium
A. You do not have Billing Account Viewer role on the billing account
B. The billing account is closed
C. The project does not exist
D. The billing report feature is disabled by default

Solution

  1. Step 1: Analyze the error message

    "Permission denied" means lack of access rights.
  2. Step 2: Identify required role for billing reports

    Billing Account Viewer role is needed to view billing reports.
  3. Final Answer:

    You do not have Billing Account Viewer role on the billing account -> Option A
  4. Quick Check:

    Permission denied = missing Billing Account Viewer role [OK]
Hint: Permission errors usually mean missing roles [OK]
Common Mistakes:
  • Assuming billing account closure causes permission errors
  • Thinking project existence affects billing report access
  • Believing billing reports are disabled by default
5. You want to reduce your monthly cloud costs. Which billing report action helps you find the biggest cost sources?
hard
A. Filter the report by service to see which services cost the most
B. Delete all projects with costs over $100
C. Disable billing reports to save money
D. Increase your budget limit in the billing account

Solution

  1. Step 1: Understand how to identify cost sources

    Filtering billing reports by service shows which services use most money.
  2. Step 2: Evaluate other options

    Deleting projects blindly or disabling reports won't help find cost sources; increasing budget doesn't reduce costs.
  3. Final Answer:

    Filter the report by service to see which services cost the most -> Option A
  4. Quick Check:

    Filter by service = find big costs [OK]
Hint: Filter reports by service to spot big costs fast [OK]
Common Mistakes:
  • Deleting projects without analysis
  • Disabling reports thinking it saves money
  • Confusing budget limits with cost reduction