I created logging export of BigQuery activities using Stackdriver Logging in the cloud console.
I found the following query, in google documentation, to extract BigQuery cost breakdown by user:
#standardSQL
WITH data as
(
SELECT
protopayload_auditlog.authenticationInfo.principalEmail as principalEmail,
protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent as jobCompletedEvent
FROM
`AuditLogsDataSet.cloudaudit_googleapis_com_data_access_YYYYMMDD`
)
SELECT
principalEmail,
FORMAT('%9.2f',5.0 * (SUM(jobCompletedEvent.job.jobStatistics.totalBilledBytes)/1000000000000)) as Estimated_USD_Cost
FROM
data
WHERE
jobCompletedEvent.eventName = 'query_job_completed'
GROUP BY principalEmail
ORDER BY Estimated_USD_Cost DESC
I can't use TABLE_DATE_RANGE in a standard SQL query. There is a way to perform the query above in a specific date range?