我可以从计费数据中得出 dataproc 集群累计的计算小时数吗?
Can I derive the number of compute hours dataproc clusters have accrued from the billing data?
我想知道是否可以通过查看计费数据获得花在 dataproc 实例上的总计算小时数。
N.B。重申一下...我对集群存在的小时数不感兴趣,我想知道总计算小时数。
我们将账单数据导出到 BigQuery,我 运行 这个查询:
select cost_grouping,cast(sum(hours) as int64) as hours
from (
select case when sku_description like 'Licensing Fee for Google Cloud Dataproc%' then sku_description
else 'vm_compute'
end as cost_grouping
, hours
from (
select sku.description as sku_description ,usage.amount_in_pricing_units as hours
from `billing.gcp_billing_export`
--we have a workload label on our dataproc clusters that we can interrogate to get all of our dataproc costs
where REGEXP_EXTRACT(TO_JSON_STRING(labels), r'"key":"workload","value":"([^,:]+)"') like 'dataproc%'
and usage.pricing_unit = 'hour'
)
)
group by cost_grouping
这给了我这个结果:
+----------------------------------------------------+-----------+--+
| cost_grouping | hours | |
+----------------------------------------------------+-----------+--+
| Licensing Fee for Google Cloud Dataproc (GPU cost) | 1 | |
| Licensing Fee for Google Cloud Dataproc (CPU cost) | 8231009 | |
| vm_compute | 8230779 | |
+----------------------------------------------------+-----------+--+
澄清一下,vm_compute小时基本上是核心小时数。
很高兴看到
(Licensing Fee for Google Cloud Dataproc (GPU cost)) + (Licensing Fee for Google Cloud Dataproc (CPU cost)) - (vm_compute) = 231
这个结果足够接近于零,我不会因为它 完全 不为零而失眠。
然后我假设 Licensing Fee for Google Cloud Dataproc (GPU cost)
和 Licensing Fee for Google Cloud Dataproc (CPU cost)
的总小时数准确反映了 Dataproc 花费的总计算小时数。那里的任何人都可以向我确认是这种情况吗?是否有任何 SKU(尚未)出现在我们的数据中,但我应该考虑哪些将来可能出现?
"GPU cost" 项目应该是正交重叠项目,并且实际价格表实际上乘以“0”,因为 Dataproc 目前不收取任何 Dataproc 特定的基础 GPU 使用费。因此,如果您对受实际 Dataproc 定价影响的计算小时数感兴趣,您应该只查看 "CPU cost"。除此之外,你是对的,查看 Licensing Fee for Google Cloud Dataproc (CPU cost)
应该是 Dataproc 花费的计算小时数的准确计数。
要记住的一个警告是,如果这是基于扁平化标签记录,那么如果您在 "key" 上匹配正则表达式,那么您最终可能会得到相同基础使用项目的重复计数;请参阅 ——例如,如果您要使用 %dataproc% 之类的键对标签求和,您最终会计算三倍或四倍的数据处理小时数。
在您的情况下,只要您在单个唯一 "workload" 键上进行过滤,数字就应该是正确的。
我想知道是否可以通过查看计费数据获得花在 dataproc 实例上的总计算小时数。
N.B。重申一下...我对集群存在的小时数不感兴趣,我想知道总计算小时数。
我们将账单数据导出到 BigQuery,我 运行 这个查询:
select cost_grouping,cast(sum(hours) as int64) as hours
from (
select case when sku_description like 'Licensing Fee for Google Cloud Dataproc%' then sku_description
else 'vm_compute'
end as cost_grouping
, hours
from (
select sku.description as sku_description ,usage.amount_in_pricing_units as hours
from `billing.gcp_billing_export`
--we have a workload label on our dataproc clusters that we can interrogate to get all of our dataproc costs
where REGEXP_EXTRACT(TO_JSON_STRING(labels), r'"key":"workload","value":"([^,:]+)"') like 'dataproc%'
and usage.pricing_unit = 'hour'
)
)
group by cost_grouping
这给了我这个结果:
+----------------------------------------------------+-----------+--+
| cost_grouping | hours | |
+----------------------------------------------------+-----------+--+
| Licensing Fee for Google Cloud Dataproc (GPU cost) | 1 | |
| Licensing Fee for Google Cloud Dataproc (CPU cost) | 8231009 | |
| vm_compute | 8230779 | |
+----------------------------------------------------+-----------+--+
澄清一下,vm_compute小时基本上是核心小时数。
很高兴看到
(Licensing Fee for Google Cloud Dataproc (GPU cost)) + (Licensing Fee for Google Cloud Dataproc (CPU cost)) - (vm_compute) = 231
这个结果足够接近于零,我不会因为它 完全 不为零而失眠。
然后我假设 Licensing Fee for Google Cloud Dataproc (GPU cost)
和 Licensing Fee for Google Cloud Dataproc (CPU cost)
的总小时数准确反映了 Dataproc 花费的总计算小时数。那里的任何人都可以向我确认是这种情况吗?是否有任何 SKU(尚未)出现在我们的数据中,但我应该考虑哪些将来可能出现?
"GPU cost" 项目应该是正交重叠项目,并且实际价格表实际上乘以“0”,因为 Dataproc 目前不收取任何 Dataproc 特定的基础 GPU 使用费。因此,如果您对受实际 Dataproc 定价影响的计算小时数感兴趣,您应该只查看 "CPU cost"。除此之外,你是对的,查看 Licensing Fee for Google Cloud Dataproc (CPU cost)
应该是 Dataproc 花费的计算小时数的准确计数。
要记住的一个警告是,如果这是基于扁平化标签记录,那么如果您在 "key" 上匹配正则表达式,那么您最终可能会得到相同基础使用项目的重复计数;请参阅
在您的情况下,只要您在单个唯一 "workload" 键上进行过滤,数字就应该是正确的。