Monitoring BigQuery User Queries: Track User Activity for Audit Purposes |

Audit User Query Activity in BigQuery |

Question

Your BigQuery project has several users.

For audit purposes, you need to see how many queries each user ran in the last month.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

To see how many queries each user ran in the last month for audit purposes in BigQuery, there are different ways to accomplish this task. Here are the explanations for each answer option:

A. Connect Google Data Studio to BigQuery. Create a dimension for the users and a metric for the amount of queries per user. Google Data Studio is a reporting tool that allows you to create interactive dashboards and reports from various data sources, including BigQuery. To use this option, you can connect Google Data Studio to your BigQuery project, and then create a report that shows the number of queries per user. You can create a dimension for the users and a metric for the amount of queries per user, and then filter the data by the last month. This option requires some knowledge of Google Data Studio and may involve additional steps to set up the connection between BigQuery and Data Studio.

B. In the BigQuery interface, execute a query on the JOBS table to get the required information. BigQuery stores information about queries in the JOBS table, including details such as the user who ran the query, the query text, and the query result. To use this option, you can execute a query on the JOBS table that retrieves the relevant information for the last month. You can use a filter on the creation time to limit the results to the last month, and then group the data by the user to see how many queries each user ran. This option requires some knowledge of SQL and the BigQuery interface.

C. Use bq show to list all jobs. Per job, use bq ls to list job information and get the required information. The bq command-line tool allows you to interact with BigQuery from the command line. To use this option, you can run the bq show command to list all jobs in your project, and then for each job, run the bq ls command to list the job information. You can filter the results by the last month and count the number of queries per user. This option requires some knowledge of the bq command-line tool and may involve additional scripting to automate the process.

D. Use Cloud Audit Logging to view Cloud Audit Logs, and create a filter on the query operation to get the required information. Cloud Audit Logging provides a way to capture and store logs for Google Cloud resources, including BigQuery. To use this option, you can view the Cloud Audit Logs for your BigQuery project and create a filter that selects only the logs for query operations. You can then filter the results by the last month and count the number of queries per user. This option requires some knowledge of Cloud Audit Logging and may involve additional steps to set up the log export and create the filter.

In summary, the most suitable option depends on your specific requirements and the tools you are familiar with. Option B is the most straightforward and requires only SQL knowledge and the BigQuery interface, while options A, C, and D may involve additional steps and tools.