For security purposes, I'd like to be able to audit who is running what kinds of queries within a certain project. Is this possible?
Using bq ls -j
from the command line gives some info; bg show -j
gives a little more. But neither show the user or the query itself.
In the CLI, you can run
bq ls -j -a
to retrieve jobs for all users in a project.Then you can run for each job id a
bq show -j <job_id>
and in order to have more details you will choose to use the json response:this returns the following format which have your query, your user and bytesprocessed etc...
Using the API you need to pass allUsers property to list jobs from all users https://cloud.google.com/bigquery/docs/reference/v2/jobs/list#allUsers