1

I have already setup billing exports as described in this link for billing analysis.

For the resources like dataset etc labels are set from console and I can do analyse resources billing in Data studio report for those labels.

However now I want to assign labels to bigquery queryjobconfig for analysis. Below is the code.

from google.cloud import bigquery
client = bigquery.Client()

sql='SELECT sum(col_name) FROM `my-project.table`'
query = (sql)
job_config = bigquery.QueryJobConfig()
job_config.labels = {'team':'development'}

query_job = client.query(
    query,
    location='US',  
    job_config=job_config )

for row in query_job:
    print(row[0])

The query is executed successfully and I can see logs in stackdriver also. But its been 48 hours I don't see entry for queryjobconfig labels in billing export tables.

Can somebody suggest what is the correct way to set label?

Neeraj Kumar
  • 836
  • 1
  • 10
  • 29
  • The code sets the lables correctly (you can verify that with `bq show -j JOB_ID`) so it can be an issue with the export or the query to poll for labels – Guillem Xercavins Feb 17 '19 at 09:12
  • 1
    Finally it appeared after almost 55 Hrs. I am not sure what caused it such delay. But finally it appeared. – Neeraj Kumar Feb 18 '19 at 11:00
  • Thanks for confirming, it was indeed due to an internal issue that caused billing data to be delayed (nothing was lost) and it's resolved by now – Guillem Xercavins Feb 18 '19 at 11:03

0 Answers0