Exporting Google Workspace Logs to BigQuery: Setup, Costs, and Useful Queries
Export Google Workspace activity logs and usage reports to BigQuery: supported editions, project permissions, setup steps, latency, costs, and starter SQL.
Last checked against Google's official documentation on .

The Admin console keeps most Google Workspace audit events for six months, and its investigation tool is built for looking up one incident at a time. Once you need a year of history, a monthly report, or a question like “which files were shared externally by the finance team last quarter,” you hit its limits and need to export Google Workspace logs to BigQuery.
BigQuery export solves this. It copies Workspace activity logs and usage reports into a dataset in your own Google Cloud project, where you can keep them as long as you like and query them with SQL. This guide covers the editions that support it, the exact setup, what it costs, and a few queries to start with.
Key Takeaways
- BigQuery export is available on Enterprise, Education Standard and Plus, Frontline, and Enterprise Essentials Plus editions.
- You need BigQuery Admin (or an equivalent role) and Project IAM Admin on the project, plus the Reports admin privilege.
- The gapps-reports service account needs editor access to write data.
- Activity logs arrive in about 10 minutes; usage reports lag 1 to 3 days.
- Billing must be enabled for activity logs; usage exports are free.
Table of contents
Open Table of contents
How the Export Works

Workspace writes two kinds of data to a BigQuery dataset you choose:
- Activity logs: individual events such as a login, a Drive share, an admin setting change, or a Gmail delivery. Google lists areas including Accounts, Admin, Calendar, Chat, Chrome, Devices, Drive, Gemini for Workspace, Gemini Notebook, Gmail, Groups, Login, Meet, Meet hardware, OAuth, Rules, and SAML. Not every report in the Admin console is available in the export.
- Usage reports: daily aggregates per user and per customer, such as storage used, emails sent, or Meet minutes.
Tables are partitioned by day, and Google notes that partitions align to Pacific Time rather than UTC or IST. That detail matters when you query a specific Indian business day.
Before You Start
Check four things:
- Edition. Your Workspace edition must be on the supported list. If you are on a Business plan, this feature is one of the reasons to compare editions; see our Business Starter, Standard and Plus plans comparison.
- A Google Cloud project with billing. Create a dedicated project such as
acme-workspace-logsin your Shared services folder. Without billing, the project runs in sandbox mode and activity logs are not exported. - Your permissions. The Workspace admin who configures the export needs BigQuery Admin (or an equivalent role) and Project IAM Admin on the project, plus the Reports administrator privilege in the Admin console.
- Domain Restricted Sharing. If your organization enforces
iam.allowedPolicyMemberDomains, allow customer IDC02h8e9nwon this project so Google’s service account can be granted access. Our organization policies guide explains the constraint.
Setup, Step by Step
- In the Cloud console, grant the service account
gapps-reports@system.gserviceaccount.comthe Editor role on the logs project (or an equivalent role that lets it create and write tables). - In the Admin console, go to Menu > Reporting > Data integrations (Education admins see BigQuery export).
- Click Edit on the BigQuery Export card.
- Tick Enable Google Workspace data export to Google BigQuery. Optionally, tick Allow export of sensitive content from data protection rule logs.
- Select the project ID.
- Enter a new dataset name. It must not already exist.
- Optionally, restrict the dataset to a location such as
asia-south1for data residency. - Click Save.
The dataset is created the day after you enable the export. If saving fails, Google’s advice is to delete the half-created dataset in the Cloud console and save again.
Changing the project, dataset or location later
Pick the project carefully, because Google’s FAQ advises against changing it. If you later select a new location, project ID or dataset ID, new data goes to a new dataset and the old dataset keeps what it already has. To carry history across, tick Backfill existing BigQuery data from the last 180 days to new dataset (180 days of audit data, 450 days of usage data). A project ID change takes effect the next day. Turning the export off stops new data but does not delete existing tables.
Latency and History
| Data | First load | Ongoing latency | History included |
|---|---|---|---|
| Activity logs | Within about 10 minutes of each event | Near real time | 180 days |
| Usage reports | 48 hours after setup | 1 to 3 days | 450 days |
The historical backfill is one of the best reasons to enable the export early. It gives you six months of activity on day one.
What It Costs
- Usage reports: no cost to export.
- Activity logs: exported with BigQuery’s streaming insert API, which has an ingestion charge.
- Storage: standard BigQuery storage pricing after the free 10 GiB a month.
- Queries: charged by bytes scanned beyond the free 1 TiB a month.
For a company of a few hundred users, the monthly cost is usually small, but it grows with Drive and Gmail activity. Two habits keep it predictable: always filter on _PARTITIONTIME and the event date, and set a budget on the project as described in our billing guide.
Starter Queries
Column names vary by service and change as Google adds fields, so check your dataset’s schema before running these. They show the pattern.
Logins outside India in the last 7 days:
SELECT email, ip_address, time_usec
FROM `acme-workspace-logs.workspace.activity`
WHERE record_type = 'login'
AND _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 8 DAY)
AND event_name = 'login_success'
ORDER BY time_usec DESC
Join the IP addresses with a geolocation table, or filter on known office ranges, to spot unusual sign-ins.
Files shared outside the domain this month:
SELECT email, drive.doc_title, drive.visibility, time_usec
FROM `acme-workspace-logs.workspace.activity`
WHERE record_type = 'drive'
AND drive.visibility = 'shared_externally'
AND _PARTITIONTIME >= TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), MONTH)
Gemini activity. Because Gemini for Workspace and Gemini Notebook events are exported too, the same pattern answers questions such as who is using Gemini in which app. Filter on the Gemini record type in your dataset’s schema rather than guessing the name, and treat these rows as sensitive, like the rest of the dataset.
Admin setting changes in the last 30 days:
SELECT email, event_name, time_usec
FROM `acme-workspace-logs.workspace.activity`
WHERE record_type = 'admin'
AND _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 31 DAY)
ORDER BY time_usec DESC
Retention and Access
The Admin console has its own retention limits. In BigQuery, check the dataset’s default table expiration straight away: Google’s export documentation warns that the default is 60 days, so exported tables are deleted after that unless you change it. Disabling the export doesn’t delete data already exported. Decide on a retention period with your compliance team, for example two years, and apply a table or partition expiration so old data is removed automatically.
Treat the dataset as sensitive. It contains email subjects, file names, and IP addresses. Grant BigQuery Data Viewer only to a security group, and avoid giving project-wide Editor to anyone except the platform team.
Visualizing the Data
Once the data is in BigQuery, you can build dashboards in Looker Studio or Connected Sheets. Useful starting dashboards include external sharing by department, failed logins by day, and storage growth by user. These are good inputs for the reviews in our audit logs guide.
Troubleshooting the Export
The Save button fails. Check that the dataset name is new, that you hold BigQuery Admin and Project IAM Admin on the project, and that the gapps-reports service account was granted access. If Domain Restricted Sharing is enforced, the grant to that service account may have been blocked; allow customer ID C02h8e9nw on the project.
The dataset never appears. It is created the day after you enable the export, so wait at least 24 hours. Then confirm the project still has billing enabled.
Usage tables exist but activity tables are empty. This usually means the project is in BigQuery sandbox mode without billing. Google notes that usage exports still work in sandbox mode, but activity log exports need billing.
Queries cost more than expected. Queries without a _PARTITIONTIME filter scan the whole table. Add partition filters to every saved query and dashboard, and set a custom BigQuery quota on the project.
You can’t filter by organizational unit. The BigQuery export has no org unit column, unlike the Reports API. Join with a user list exported from the Admin console or Directory API if you need department or OU reporting.
Times look a day off. Remember that partitions align to Pacific Time. Convert time_usec to Asia/Kolkata when you report on Indian business days:
SELECT DATETIME(TIMESTAMP_MICROS(time_usec), 'Asia/Kolkata') AS ist_time, email, event_name
FROM `acme-workspace-logs.workspace.activity`
WHERE _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 2 DAY)
LIMIT 100
Monthly Reports Worth Automating
Once the export is stable, schedule a few queries with BigQuery scheduled queries and send results to a sheet or dashboard:
| Report | Why it matters |
|---|---|
| Files shared externally, by user and department | Spot oversharing before it becomes a leak |
| Failed and suspicious logins by day | Early warning of password attacks |
| New OAuth app authorizations | Find unapproved apps reaching company data |
| Admin role and setting changes | Change control and audit evidence |
| Storage growth by user | Plan licenses and storage policies |
Our Google Workspace storage management guide explains what to do with the storage numbers once you have them.
BigQuery Export Versus Sharing Logs With Cloud Logging
There is a second way to get Workspace audit data into Google Cloud. In the Admin console, a super admin can go to Account > Account settings > Legal and compliance > Sharing options and enable sharing Workspace data with Google Cloud services. Selected Workspace audit logs then appear in Cloud Logging in near real time, alongside Google Cloud’s own audit logs: Admin, Groups Enterprise, and user log events on all supported editions, OAuth and SAML events on Enterprise Standard and Plus, Education Standard and Plus, Voice Premier and Cloud Identity Premium, and Access Transparency events on Enterprise Plus and Education. Retention then follows Google Cloud’s audit log policy, not the Admin console’s.
The two approaches suit different jobs:
| BigQuery export | Sharing with Cloud Logging | |
|---|---|---|
| Best for | Reporting, long-term analysis, dashboards | Alerting and routing to a SIEM |
| Data | Activity logs and usage reports | Admin, Groups, user, and (on some editions) OAuth, SAML, and Access Transparency audit logs |
| Query language | SQL | Logging query language, or SQL through Log Analytics |
| Routing | Stays in the dataset | Log sinks to Pub/Sub, buckets, or BigQuery |
Many organizations use both: BigQuery for monthly reports and investigations, and Cloud Logging sinks to feed real-time alerts into a security tool. If you use log sinks, apply the same retention and access rules as for the BigQuery dataset.
Conclusion
BigQuery export turns Workspace logs from a short-term lookup tool into a long-term security and reporting asset. Set it up in a dedicated project with billing and a budget, keep the dataset locked down, and start with a handful of simple queries.
If you are evaluating editions, BigQuery export is a meaningful difference between Business and Enterprise plans of Google Workspace. Tomorrow’s guide covers Apps Script and Google Cloud projects, including the OAuth consent screen.
Official Google documentation:
Related reading:
- Google Workspace Audit Logs Guide: what each log contains.
- Google Cloud Billing: Budgets and Alerts: keep export costs in check.
- Google Workspace DLP Guide: DLP events you can analyze in BigQuery.
This guide contains referral or affiliate links. If you sign up through one, Workspace Blog may earn a commission at no extra cost to you. Read our referral and advertising disclosure.
Frequently Asked Questions
- Which Google Workspace editions support BigQuery export?
- Google lists Frontline Standard and Plus, Enterprise Standard and Plus, Education Standard and Plus, and Enterprise Essentials Plus. Business Starter, Standard, and Plus do not include the BigQuery export.
- How quickly do Workspace logs appear in BigQuery?
- According to Google, activity log events are typically available within 10 minutes. Usage reports have a 48-hour delay after the first configuration, then usually lag by 1 to 3 days.
- Does exporting Workspace logs to BigQuery cost money?
- Usage report exports have no cost. Activity log exports use BigQuery's streaming insert API, which has ingestion charges, and you also pay for BigQuery storage and queries beyond the free tier. Billing must be enabled on the project, otherwise activity logs are not exported.
- How much historical data is exported when I turn it on?
- Google's documentation says the export includes 180 days of historical activity data and 450 days of usage data. After that, data accumulates in BigQuery, but Google warns the default table expiration is 60 days, so change the dataset's expiration setting if you want to keep data longer.
- Why does the BigQuery export setup fail to save?
- Common causes are a dataset name that already exists, missing permissions on the project for the admin or for the gapps-reports@system.gserviceaccount.com service account (which needs Editor or an equivalent role), billing not enabled, or Domain Restricted Sharing blocking the service account. Google asks you to allow customer ID C02h8e9nw in that policy.