How to find who uses BigQuery

Galaxy Glossary

Who uses BigQuery and how can I list those users?

Identify which user principals are running jobs in your BigQuery project by querying audit and INFORMATION_SCHEMA views.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why would I want to know who uses BigQuery?

Knowing the active user list helps control costs, tighten security, and allocate training resources.

Which tables store user activity in BigQuery?

Job-level metadata lives in <region>.INFORMATION_SCHEMA.JOBS_BY_* views and Cloud Audit Logs. These views expose principal_email for every job.

How do I list query runners in the last 30 days?

Filter JOBS_BY_ORGANIZATION on creation_time and aggregate by principal_email. Limit the window to avoid scanning an excessive partition.

SELECT principal_email,
COUNT(*) AS job_count,
SUM(total_bytes_processed/1e12) AS tb_scanned
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_ORGANIZATION
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
AND job_type = 'QUERY'
GROUP BY principal_email
ORDER BY job_count DESC;

Tip

Replace region-us with your datasets region to avoid cross-region charges.

How can I see which tables each user touches?

Join JOBS_BY_PROJECT to JOBS_TIMELINE_BY_PROJECT or parse the referenced_tables array to break down activity by table.

Can I automate notifications for new users?

Schedule a query that compares todays user list against a reference table and pushes a Pub/Sub message when a new email appears.

Best practices for tracking BigQuery users

Partition by creation_time, leverage WITH CONNECTION scheduled queries, and store snapshots in a low-cost tier for audit purposes.

Common pitfalls

Querying the wrong region or scanning entire history dramatically raises cost. Forgetting to include service accounts skews usage totals.

Why How to find who uses BigQuery is important

How to find who uses BigQuery Example Usage


-- Who queried the Products table in the last 24 hours?
SELECT principal_email,
       COUNT(*) AS queries,
       ROUND(SUM(total_bytes_processed)/1e9,2) AS gb_scanned
FROM  `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 24 HOUR)
  AND JSON_EXTRACT_SCALAR(referenced_tables, '$[0].table_name') = 'Products'
GROUP BY principal_email
ORDER BY gb_scanned DESC;

How to find who uses BigQuery Syntax


-- Basic syntax to discover users running jobs
SELECT principal_email [, agg_functions]
FROM  `&lt;region&gt;.INFORMATION_SCHEMA.JOBS_BY_<SCOPE>`
WHERE creation_time BETWEEN <start_ts> AND <end_ts>
  [AND job_type = 'QUERY']
GROUP BY principal_email
ORDER BY <metric> DESC;

-- Example (E-commerce project)
-- Which analysts updated the Orders table this week?
SELECT principal_email,
       COUNT(*) AS updates
FROM  `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
  AND referenced_tables LIKE '%Orders%'
  AND job_type = 'QUERY'
GROUP BY principal_email;

Common Mistakes

Frequently Asked Questions (FAQs)

Does BigQuery store historical job data forever?

Job metadata is retained for 180 days by default. Export audit logs if you need longer history.

Will these queries add noticeable cost?

No. INFORMATION_SCHEMA views are metadata tables and cost $0 to scan; only bytes read outside those views incur charges.

Can I track usage per dataset instead of user?

Yes. Aggregate on project_id, dataset_id, or parse referenced_tables to see dataset-level traffic.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.