英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论