GCP Billing Dashboard 完全指南

数据延迟
~24h
费用数据延迟
预算告警
免费
基础告警
成本分配
标签+项目
灵活归因
折扣机制
CUD/Spend
多种选项

$ gcloud billing describe --project=my-project

在三大云厂商中,Google Cloud 的计费系统可能是最"技术流"的。它不像 AWS 那样有眼花缭乱的服务组合,也不像 Azure 那样深度集成 Microsoft 生态,而是以简洁透明著称。今天我们就来聊聊 GCP 的 Billing Dashboard。

GCP Billing Dashboard 核心功能

1. Billing Account 结构

理解 GCP 的计费结构是第一步:

小提示:一个 Billing Account 可以管理多个项目,但一个项目只能绑定一个 Billing Account。

2. Cost Breakdown(费用分解)

Dashboard 提供多种费用视图:

3. 预算和告警(Budgets & Alerts)

GCP Billing 允许你设置:

gcloud beta billing budgets create \
  --billing-account=BILLING_ACCOUNT_ID \
  --display-name="Monthly Budget" \
  --amount=10000 \
  --threshold-rule-threshold-percent=0.9 \
  --threshold-rule-spend-basis=SPECIFIED_AMOUNT

4. 费用导出(Cost Export)

这是 GCP 的杀手级功能 - 将计费数据导出到 BigQuery:

强烈建议: 开启 Billing Export 到 BigQuery,这是 GCP FinOps 的基础数据来源。

高级分析:BigQuery Billing 挖掘

查询空闲资源

SELECT 
  resource.type,
  resource.name,
  SUM(cost) as total_cost
FROM `gcp_billing_export`
WHERE DATE(_PARTITIONTIME) >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
  AND service.description = 'Compute Engine'
GROUP BY resource.type, resource.name
HAVING SUM(cost) > 0 AND COUNT(*) > 0

Top 10 费用 SKU

SELECT 
  sku.description,
  SUM(cost) as total_cost,
  ROUND(SUM(cost) * 100 / SUM(SUM(cost)) OVER(), 2) as pct
FROM `gcp_billing_export`
WHERE DATE(_PARTITIONTIME) >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY sku.description
ORDER BY total_cost DESC
LIMIT 10

GCP 成本优化策略

1. Committed Use Discounts (CUDs)

类似于 AWS RI 和 Azure RI:

2. Preemptible VM / Spot

GCP 的抢占式虚拟机:

3. Committed Use Discounts + Spot 混搭

最佳实践:用 CUD 覆盖基线负载,Spot 处理峰值波动。

标签策略

GCP 推荐使用以下标签进行成本归因:

GCP Billing Dashboard 让你的 Google Cloud 账单清晰可控!

$ share --net https://981263.xyz/S-003-GCP-Billing-Dashboard.html

Practical review before using this page

The S 003 GCP Billing Dashboard resource should be read together with the rest of Cloud Cost Optimization Dashboard, not as an isolated shortcut. Before acting on the page, write down the current baseline, the assumption you are making, and the result you expect to see. This makes the page more useful for comparison and reduces the chance of changing several variables at once.

For FinOps planning, cloud cost allocation, rightsizing, tagging governance, and monthly cost review, a good review habit is to separate stable facts from estimates. Stable facts might include dates, page URLs, account names, measured values, or the exact checklist items you completed. Estimates should be labeled as estimates and revisited later. If the result affects money, health, safety, compliance, or operational risk, use the page as preparation for a more careful review rather than as the final authority.

Common mistakes to avoid

Use this page as a planning reference before changing cloud accounts. Confirm pricing, contracts, and technical limits in the relevant provider console because cloud terms can change.