Batch : detailed job cost

Is there a recommended way of answering the question “How much did I just spend on a given batch job?” We’re planning on running some large, expensive computations on batch and between the job overhead and the vagaries of spot pricing, it would be nice to know in near-real-time. Thanks!

1 Like

Hi @ericmjonas ,

Welcome to Google Cloud Community!

With regards to your question, you may check the Google Cloud Pricing Calculator first to check for the estimated costs of each Google Cloud products and services.

Please be advised that the computations displayed here are just estimates and the actual fees may be higher or lower. Some factors that could affect pricing include region, setup, usage among others.

Hope these information helped you out.

1 Like

You are quite correct that there are a myriad of factors that can cause a quickly-estimated job cost to be off, sometimes by a considerable amount. I am sure that google is in fact logging this information (otherwise how could they bill me), but I need a way of tracing it back to a given job ID. I believe AWS Batch provides this functionality out of the box.

1 Like

@ericmjonas Compute resources (like VMs) used by a Batch job are labelled by the job ID. If you have access to a project’s Billing account, you can go to Billing>Report and filter the cost associated with a label, job ID in this case.

However, this is not near real time. It has several hours of delay at the moment.

1 Like

@bolianyin This is exactly what I was looking for – it’s unfortunate about the reporting latency but that’s ok. Is there an API to query the billing reports? I tried looking at the various billing Apis but couldn’t find anything.

1 Like

@ericmjonas I did not find reporting API from the billing api page, so I am not sure if Billing has an API for that. Probably you can post a Billing specific question and get help from someone more knowledgeable about Billing, and link to this question as the use case.

1 Like

@ericmjonas - Here is a link to Batch documentation on how to add labels to the job’s allocation policy and then filter on those labels within the Cloud Billing Report.