How do you analyze BigQuery audit logs and INFORMATION_SCHEMA.JOBS for usage analysis and chargeback?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
How do you analyze BigQuery audit logs and `INFORMATION_SCHEMA.JOBS` for usage analysis and chargeback?
```hint Pick the cost driver
How the organization pays for compute decides which column of the jobs views you allocate by.
```
```hint Watch for double counting
Some rows in the jobs views summarize other rows. Check which ones before you sum.
```
### Clarifying Questions to Ask
- Is compute paid on demand, through capacity reservations (Editions), or a mix of both?
- Should chargeback cover a single project or the whole organization, and in which regions?
- Who are the cost owners (teams, projects, pipelines), and is there a reliable mapping from users and service accounts to them?
- Does the chargeback include storage and other non-query costs, or only query compute?
### What a Strong Answer Covers
- Which jobs view and columns to use, and their scope and retention limits
- A cost formula for on-demand and for capacity pricing, including how idle capacity is allocated
- How jobs are attributed to teams (labels, service account mapping, project)
- What audit logs add that the jobs views do not, and how to keep them long term
- Pitfalls that distort the numbers, such as double counting and regional scope
### Follow-up Questions
- How would you keep job history beyond the 180-day retention of the jobs views?
- A reservation is shared by five projects. How do you split its monthly bill fairly, idle slots included?
- How would you find the queries that drove most of last month's cost, and what would you do about them?
- How would you reconcile estimates from the jobs views with the Cloud Billing export?
Overview: Asks how to use BigQuery INFORMATION_SCHEMA.JOBS views and Cloud Audit Logs to analyze usage and charge costs back to teams. It tests cost formulas for on-demand and capacity pricing, job attribution with labels, retention limits, and pitfalls such as double-counted script jobs.