For warehouse administrators
Reviewing a read-only access request for dwhat
Someone on your team would like to audit your warehouse's compute cost with dwhat, and needs you to create the account it reads with. This page says what that account can see, what dwhat keeps and for how long, how to take the access back, and what it costs to run — so you can decide before you run anything.
What the audit is for
dwhat reads the warehouse's query history and works out where compute spend went: by day, by user, by dbt model and by dashboard, with the 20 most expensive queries and a fix hint where the warehouse's own statistics support one. After the first read it keeps reading every few hours, emails the person who connected it when a day costs much more than usual, and builds a monthly report for finance.
Exactly what it reads
BigQuery
INFORMATION_SCHEMA.JOBS_BY_PROJECT, for one project and one region: finished query jobs that billed bytes or slot time. Script parent jobs and free cache hits are left out.
| Column | Why |
|---|---|
job_id, creation_time | to count each job once and put it on a UTC day |
user_email | the user or service account that ran it — cost by user |
statement_type | SELECT, MERGE, CREATE TABLE AS… |
query (first 20,000 characters) | to group identical queries, find dbt and BI tool comments, and base fix hints on |
labels | dbt and Looker Studio job labels — cost by model and dashboard |
total_bytes_billed, total_bytes_processed, total_slot_ms | the cost |
elapsed time, cache_hit | shown with the most expensive queries |
Snowflake
SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORY joined to QUERY_HISTORY, for the whole account.
| Column | Why |
|---|---|
query_id, start_time | to count each query once and put it on a UTC day |
user_name | the Snowflake user that ran it — cost by user |
warehouse_name, query_type | where it ran, and what kind of statement it was |
query_text (first 20,000 characters) | to group identical queries, find dbt and BI tool comments, and base fix hints on |
query_tag | dbt and dashboard tags — cost by model and dashboard |
credits_attributed_compute | the cost |
bytes_scanned, total_elapsed_time, bytes_spilled_to_remote_storage, partitions_scanned, partitions_total | the evidence a fix hint needs |
And from WAREHOUSE_METERING_HISTORY, each warehouse's compute credits per UTC day, so idle time can be shown next to what queries used.
These are the only queries dwhat runs. The roles below allow more than that: BigQuery Resource Viewer lets the account see the metadata of the project's other BigQuery resources, and the SNOWFLAKE database roles let the user read more of ACCOUNT_USAGE than these views. Neither grants a single row of your tables, or any change.
What that metadata can contain
- Query text is stored as the warehouse recorded it. Anything typed into a query — customer ids, e-mail addresses, names or amounts in a WHERE clause, values in an INSERT — is in it.
- User names are usually people's e-mail addresses or logins, and they are shown next to what each person's queries cost.
- Labels, query tags, warehouse names and dbt model names can say what a project is about.
- None of this is filtered or masked. Treat the history dwhat holds as being as sensitive as your query history is.
Where the credentials are kept
- BigQuery: the JSON key is entered only in the signed-in connection form. dwhat keeps the key's client email, private key and token address, encrypted with AES-256-GCM under a server key that is not stored in the database. No page or API response shows it again.
- Snowflake: dwhat generates the key pair. The private half is encrypted the same way and never shown to anybody; the public half is the one in the setup script. The service user has no password.
- An encrypted credential is bound to its connection, so it cannot be decrypted for any other.
How long the history is kept
- The first read covers the last 45 days. After that the connection is read again every few hours, from where it stopped, with a day of overlap.
- Query history is kept for 400 days; older days are deleted every day.
- Removing the connection in dwhat deletes its stored credentials and every query, alert and upload read from it, at once.
- dwhat's server logs record connection ids, row counts and error messages — for a failed read, the status and up to 300 characters of the warehouse's own error message. dwhat does not write query text, history rows or credentials to them.
Taking the access back
Remove the account on your side and dwhat can read nothing more; whoever connected it can also remove the connection in dwhat, which deletes what was read. With the default names:
Snowflake
USE ROLE ACCOUNTADMIN; DROP USER IF EXISTS DWHAT_READER; DROP ROLE IF EXISTS DWHAT_READER; DROP WAREHOUSE IF EXISTS DWHAT_XS;
BigQuery
PROJECT=your-project-id gcloud iam service-accounts delete dwhat-reader@$PROJECT.iam.gserviceaccount.com \ --project=$PROJECT
What it costs to run, and its limits
- Snowflake: The reads run on dwhat's own X-Small warehouse, which suspends after a minute idle: a few minutes of X-Small a day.
- BigQuery: Each read is one query on INFORMATION_SCHEMA, billed to the project like any other (on demand, INFORMATION_SCHEMA queries have a 10 MB minimum). A few a day.
- Costs are compute only, at the rate set on the connection — list price until it is changed. Storage, data transfer and Snowflake cloud services are not included.
- BigQuery: one connection reads one project in one region.
- Snowflake: the per-query cost lags by up to eight hours, and very short queries and idle time are left out of it by Snowflake. dwhat shows idle time separately, from warehouse metering.
- Model and dashboard attribution comes only from marks the tools leave (dbt's query comment and labels, Looker Studio labels, Looker and Metabase comments, a dashboard label or query tag). A query without one is shown as unattributed.
The Snowflake setup
Run as ACCOUNTADMIN, or a role that can create roles, users and warehouses. It creates a role that can read account usage and nothing else, an X-Small warehouse for it that suspends after a minute idle, and a service user with no password. The key pair is generated by dwhat for each connection: the person who asked you will send this script with their connection's public key filled in. The public key is safe to forward; the private half never leaves dwhat.
USE ROLE ACCOUNTADMIN; -- A role that can read account usage, and nothing else. CREATE ROLE IF NOT EXISTS DWHAT_READER; GRANT DATABASE ROLE SNOWFLAKE.USAGE_VIEWER TO ROLE DWHAT_READER; GRANT DATABASE ROLE SNOWFLAKE.GOVERNANCE_VIEWER TO ROLE DWHAT_READER; -- Its own X-Small warehouse, suspended after a minute idle, -- so reading the history costs a few minutes of X-Small a day. CREATE WAREHOUSE IF NOT EXISTS DWHAT_XS WAREHOUSE_SIZE = XSMALL AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = TRUE; GRANT USAGE ON WAREHOUSE DWHAT_XS TO ROLE DWHAT_READER; -- A service user with no password: it signs in with a key pair only. CREATE USER IF NOT EXISTS DWHAT_READER TYPE = SERVICE DEFAULT_ROLE = DWHAT_READER DEFAULT_WAREHOUSE = DWHAT_XS RSA_PUBLIC_KEY = '<the public key shown on your connection page>'; GRANT ROLE DWHAT_READER TO USER DWHAT_READER;
The BigQuery setup
A service account with two roles on the project — BigQuery Resource Viewer to see everybody's jobs, BigQuery Job User to run the query that reads them — and a JSON key for it. With the gcloud CLI:
PROJECT=your-project-id SA=dwhat-reader@$PROJECT.iam.gserviceaccount.com gcloud iam service-accounts create dwhat-reader \ --project=$PROJECT --display-name="dwhat (read-only)" # Sees everybody's job metadata in the project. No table data. gcloud projects add-iam-policy-binding $PROJECT \ --member="serviceAccount:$SA" --role=roles/bigquery.resourceViewer # Runs the one query that reads that metadata. gcloud projects add-iam-policy-binding $PROJECT \ --member="serviceAccount:$SA" --role=roles/bigquery.jobUser gcloud iam service-accounts keys create dwhat-key.json --iam-account=$SA
The JSON key is a credential. Hand it over through your team's approved secret-sharing process, never by email, chat or ticket. It is entered only in dwhat's signed-in connection form, by the person adding the connection.
Nothing to sign up for
You do not need a dwhat account to review or run any of this. The person who asked you adds the connection and presses "Test connection" once you tell them the setup has run. The same scripts, and the CSV route for teams that will not grant access at all, are on the free audit page.