如何通过作业ID在BigQuery中获取成本。

huangapple go评论57阅读模式
英文:

How to get costs in bigquery by job id

问题

我想获取我运行的每个作业的成本。
我知道在表billing.gcp_billing_export_v1_XXXXX中有计费信息,但我找不到通过作业ID连接它的方法。我还知道在表region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT中有成本信息。
我感到困惑,我该如何知道正确的计算成本的方法,以及如何通过作业ID获取成本?

我尝试过连接上述两个表,但无法连接,因为它们的粒度不同。

我需要能够自动计算成本,而不是手动使用Google Cloud Pricing(GCP)计算器。

英文:

I want to get the cost of each job I run.
I know that in this table billing.gcp_billing_export_v1_XXXXX there is billing information but I can't find a way to connect it by job id. I also know that in this table region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT there is costs info.
Im confused, how can I know what is the right way to calc the costs and how can I get the costs by job id?

I have tried to connect between the 2 above tables but couldn't because they have different granularity.

I need to be able to calculate it automaticlly and not manually with Google Cloud Pricing (GCP) Calculator

答案1

得分: 2

以下是翻译好的部分:

"Assuming you are using default on-demand pricing plan, the cost of a query is $5 per scanned TB in US region as seen in BigQuery pricing page.

You then get the cost of each job with:

select 
  job_id, 
  ifnull(5. * (total_bytes_billed / pow(2, 40)), 0) as job_cost
from `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT

(1 TB = 2^40 bytes)"

英文:

Assuming you are using default on-demand pricing plan, the cost of a query is $5 per scanned TB in US region as seen in BigQuery pricing page.

You then get the cost of each job with:

select 
  job_id, 
  ifnull(5. * (total_bytes_billed / pow(2, 40)), 0) as job_cost
from `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT

(1 TB = 2^40 bytes)

huangapple
  • 本文由 发表于 2023年2月19日 20:12:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500051.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定