Connecting Metabase to Google BigQuery with a service account

Connect a self-hosted Metabase to BigQuery with a service account JSON key, the three IAM roles it needs, scoped datasets and a key storage plan you can audit.

On this page

How Metabase connects to BigQuery with a service account

A team that wants Metabase querying BigQuery datasets on infrastructure it controls needs a credential Metabase can use without a person signing in. The supported method is a Google Cloud service account whose JSON key is entered in the BigQuery connection form in Metabase's admin settings. Metabase authenticates to Google with that key on every sync, scan and query, so the account's IAM roles define what Metabase can reach. Three roles are required: BigQuery Data Viewer, BigQuery Metadata Viewer and BigQuery Job User. Data Viewer reads table contents, Metadata Viewer lets Metabase discover tables and columns for its schema sync, and Job User lets it run query jobs in the project that is billed for them. Grant each role at the level the design requires, and confirm the current role names and permissions in Google's IAM documentation before you build the policy.

This page covers three decisions in order: creating the service account, scoping it to the datasets Metabase should see, and protecting the JSON key on your server. Scoping matters because the three roles do not, by themselves, limit Metabase to particular datasets. Grant Data Viewer on specific datasets rather than the whole project where your data layout allows it, and decide which projects Metabase should be able to query before you enter the key. Metabase's own BigQuery connection documentation describes the connection fields and should be the reference for the exact form inputs in your Metabase version.

The key itself is the sensitive part. Google allows the JSON key to be downloaded only once, so store it in your secrets system at the moment it is created, and plan for loss: if the file is deleted, you must create a new key or a new service account with the same roles and update the connection. Limit who can read the key on the Metabase host, keep it out of shell history, configuration files committed to source control and backups that are not encrypted, and record who created it and when. Confirm with your security team how key rotation will be scheduled and evidenced, since a key that is never rotated is a long-lived credential on a server that people administer.

What you need before you start

Five things must be in place before you create the service account: a Google Cloud project with the datasets you plan to query, rights to manage IAM, a running self-hosted Metabase with an admin account, and a safe home for the key. The network path from Metabase to Google's APIs is the one most often overlooked.

Google Cloud project and datasets

Identify the Google Cloud project that holds the BigQuery datasets Metabase will sync, and list the datasets by name before you start. Metabase connects per project, so the project ID you enter must match the one that owns the data. If your analysts query across several projects, note each one now, because database routing for BigQuery only works between databases in different projects.

Database routing docs

Rights to manage IAM

Confirm that the person running the setup can create service accounts, grant IAM roles on the project, and create a JSON key. In many organizations these rights sit with a platform or cloud security team, not the analytics team, so request them early. Ask the cloud owner to approve the three roles before the key is generated, since the key inherits whatever the account can reach.

Self-hosted Metabase with an admin

You need a running self-hosted Metabase and an administrator account that can add databases in the Admin settings. Check that the instance uses a PostgreSQL or MySQL application database rather than the embedded H2 database, because H2 is meant for demos. Confirm the Metabase version you run in the version support page and in the BigQuery connection docs for that release, since driver behavior can differ between versions.

Metabase version support

Outbound path to Google APIs

The Metabase server must reach Google's BigQuery API endpoints over HTTPS. If the server sits in a restricted network, a proxy or egress rule may block the call, and the connection test will fail with a generic error. Ask your network team to allow outbound HTTPS from the Metabase host to Google APIs, and confirm whether your policy requires a proxy setting for the JVM.

Secure storage for the JSON key

Choose where the JSON key will live before you download it. Google allows the key file to be downloaded only once, so plan a secret store or a restricted, backed-up location with access limited to the Metabase administrators. Avoid email, shared drives and chat. Record who holds the key, because rotation means creating a new key and revoking the old one.

Configure the service account and connection in order

This sequence creates a dedicated Google Cloud service account, grants it the three roles Metabase needs, and connects Metabase to BigQuery with a single JSON key. Each step ends with a check so you know the connection works before users depend on it.

  1. Choose the project and enable BigQuery

    A cloud administrator selects the Google Cloud project that hosts the datasets Metabase will query and confirms the BigQuery API is enabled there. Record the project ID, since you will need it when you add the database in Metabase. Done means the project appears in the console with BigQuery available and its datasets are visible to the administrator. If the datasets sit in several projects, list each one now, because Metabase handles cross-project access differently from a single project.

  2. Create a dedicated service account

    In IAM, the administrator creates one service account for Metabase, named so it is clearly tied to this instance and not to a person. Avoid reusing an existing application account, so that revoking Metabase access later does not affect other workloads. Done means the service account exists in the chosen project and appears in the IAM list with its email address recorded.

  3. Grant the three BigQuery roles

    Grant the service account the BigQuery Data Viewer, BigQuery Metadata Viewer and BigQuery Job User roles. Data Viewer lets Metabase read table data, Metadata Viewer lets it read schema information for sync, and Job User lets it run query jobs. Scope the grants to the project or datasets Metabase needs, and confirm the current role names and scoping options in Google's console or the Metabase BigQuery documentation. Done means the IAM policy for the account lists exactly these three roles and no broader owner or editor role.

  4. Generate and store one JSON key

    Create a JSON key for the service account and download it to a secure location on the administrator's workstation. Google allows this file to be downloaded only once, so store it immediately in your secrets manager and do not email or commit it. If the key is lost or deleted, you must create a new key or a new service account with the same roles and update Metabase. Done means the file is saved in the secrets manager and the local copy is removed after upload.

  5. Add the BigQuery database in Metabase

    As a Metabase administrator, open Admin settings, choose Add database, select BigQuery, and paste the project ID and the contents of the JSON key into the connection form. Choose which sync and scan options to keep for this first connection. Done means Metabase saves the database and reports a successful connection test. If the test fails, check the project ID, confirm the key belongs to that project, and verify the three roles have propagated.

  6. Run a sync and verify tables appear

    Trigger a manual sync from the database settings page and wait for it to finish. Open the Browse data view and confirm that the expected datasets, tables and columns are listed. Then run a simple test query in the query builder or SQL editor against a known table and check that results return. Done means the test query succeeds and the schema matches what the administrator sees in BigQuery. If expected datasets are missing, review which datasets the service account can see.

  7. Confirm an unauthorized user cannot see the dataset

    Sign in as a test user who is in a group without data permissions for this database, or create one for the check. Confirm that the BigQuery database and its tables are not visible or are blocked in the Browse data view and in the query builder. Then confirm the same for a direct SQL attempt. Done means the test user sees no data from the connection. Remember that the service account controls what Google returns, while Metabase group permissions control what each Metabase user can open, so both layers need testing.

Which BigQuery roles Metabase needs and why

Metabase needs three IAM roles on the service account it uses for BigQuery: BigQuery Data Viewer, BigQuery Metadata Viewer and BigQuery Job User. Each covers a different part of the connection. BigQuery Data Viewer lets Metabase read the table data that questions and dashboards query. BigQuery Metadata Viewer lets it read table and dataset metadata, which sync uses to discover tables and field types so that the query builder and filters work. BigQuery Job User lets the service account run query jobs, and those jobs are billed to the project you choose as the billing project, so this role is the one that connects the account to a project where query charges land.

Grant each role at the narrowest scope that still works for your data model. If your datasets sit in one project and you only want Metabase to see a few of them, grant Data Viewer and Metadata Viewer on those datasets rather than on the whole project. Project-level grants are simpler to manage but make every table in the project reachable by anyone who obtains the JSON key. Job User is usually granted at project level because it governs where jobs run, not which data is read. Confirm the exact role names, scope options and any additional permissions against the current Metabase BigQuery documentation before rollout, since the requirements can change between Metabase releases.

Treat the scope decision as part of the security design, not an administrative detail. The JSON key is the only credential Metabase holds for BigQuery, so anything the service account can read is reachable by whoever gets that file. Narrow grants limit the damage from a leaked key, and they also make the access review simpler, because you can list exactly which datasets each Metabase connection can read. Record the chosen scope in your change ticket so that a later request to widen it goes through the same review as the original grant.

Mapping BigQuery projects, datasets and Metabase databases

This table maps each BigQuery project and dataset your team needs to a Metabase database connection, with the sync scope decision and the data owner for each. Read it before creating the service account so the roles are granted in the right projects. Cross-project designs need a routing check before rollout because database routing with BigQuery only works between databases in different projects.

Project or datasetSync scope decisionQuery job project and rolesData owner
Analytics project, curated datasetsSync only the curated datasets that dashboards useQuery jobs billed to this project; Job User role granted hereData platform team, named per dataset
Raw ingestion projectUsually exclude from sync; expose through curated views insteadAvoid granting Data Viewer here unless analysts need raw tablesData engineering team
Finance reporting datasetSync only the tables approved for finance usersData Viewer and Metadata Viewer on this dataset; Job User on the query projectFinance controller or named data steward
Customer data dataset with personal dataSync only after access review; confirm which columns are includedGrant the narrowest viewer role the service account needsPrivacy or compliance owner, confirmed in writing
Second project for cross-project reportingPlan a separate connection or confirm routing support before rolloutConfirm the service account roles in each project involvedOwner of the second project; confirm with them
Sandbox or test projectSync only if people need a non-production copySeparate service account and key recommended for test useTeam that owns the sandbox

Protecting the JSON key on a self-hosted server

The service account JSON key is the credential that lets Metabase read your BigQuery data, so it needs the same care as any production secret. The cards below cover where the key lives, who can reach it, how it rotates, and how to see who uses it.

Store the key on first download

Google lets you download the JSON key only once. Save it straight into a secrets manager or restricted vault at that moment, and do not leave a copy in a downloads folder or a ticket attachment. If the file is lost, you cannot recover it, so the fallback is a new key or service account with the same roles. Confirm that your vault records who reads the secret and when.

Key download
Once
Metabase BigQuery docs

Grant only the three roles

Bind the service account to the BigQuery Data Viewer, BigQuery Metadata Viewer and BigQuery Job User roles, and to no others. Scope the data viewer grant to the datasets Metabase should sync where your IAM design allows it, rather than to the whole project. Avoid owner or editor roles, which would let the key change data or IAM policy if it leaked.

Limit who can open admin settings

Anyone who is a Metabase admin can view and change the database connection, so the BigQuery credential is only as protected as that admin group. Keep the admin group small, use named accounts rather than shared logins, and review membership on a fixed schedule. Confirm that the people who can edit the database connection are the same people who are approved to hold the key.

Rotate by replacing, then removing

To rotate, create a new key on the existing service account or a new service account with the same three roles. Update the Metabase connection, test a sync and a question against each dataset, and only then delete the old key in Google Cloud. Deleting the old key first can break every saved question and sync that uses it. Record the rotation date and the owner in your change log.

Keep the key off disks, logs and backups

The key should not sit on a shared disk, in a Git repository, in a container image, or in a configuration file that backups copy. Check that Metabase logs and support bundles do not print the connection details, and exclude any temporary key files from server backups. Confirm the file permissions on the host and remove any local copy once Metabase has loaded the credential.

Audit service account use

Turn on Google Cloud audit logging for BigQuery and IAM activity, then review who created or downloaded keys and which jobs the service account ran. Alert on key creation events and on queries from unexpected source addresses or at unusual hours. Ask your Google Cloud administrator which log sinks retain these records and for how long, since that retention sets how far back an investigation can look.

How to verify the BigQuery connection before users rely on it

Verify the connection in a fixed order before any group is told to use it. First, confirm that the BigQuery connection saves in the Metabase admin settings and that the sync and field scan finish without errors, since a saved connection only proves the JSON key was accepted. Then run one native query and one query built in the graphical query builder against a small, known table in a dataset the test service account can read. Both should return the same result, and the row count should match a SELECT COUNT(*) run directly in the BigQuery console using the same service account or an equivalent principal. If the counts differ, check which project and dataset Metabase is pointed at before suspecting the driver.

Next, test access boundaries with a real non-admin account. Place a test user in a group that has been granted only the datasets it should see, then confirm that the user can open those tables and cannot browse or query any other dataset in the project. Remember that the three IAM roles on the service account are project-level grants, so the Metabase data permissions are the layer that limits what people see. Confirm the group's permissions in Metabase rather than relying on the IAM roles alone. If you plan to use database routing, test it separately, because BigQuery only routes between databases in different projects according to the Metabase documentation.

Finally, check that activity lands where your finance and security teams will look for it. Open the BigQuery job history for the project and confirm that the test queries appear under the service account, with the expected bytes processed and job status. Compare those jobs with the queries you ran in Metabase. Record the outcome in a short test log that includes the Metabase version, the date of the test, the project and datasets tested, the group tested, and the pass or fail result for each step. Keep this log with your change records, and repeat the same steps after any Metabase upgrade or change to the service account.

Common BigQuery connection failures and fixes

This table lists the failures teams most often hit when Metabase connects to BigQuery with a service account, with the likely cause and the fix for each. Read it by matching the symptom you see to a row, then checking the IAM bindings and key status it points to. Most failures come from a missing role, a project mismatch or a key that can no longer be downloaded.

SymptomLikely causeFix
Sync finds no tables or datasetsThe service account lacks BigQuery Data Viewer or BigQuery Metadata Viewer on the datasets, so Metabase cannot list their contentsConfirm both roles are granted on the datasets or project Metabase should read, then trigger a manual sync
Query jobs fail with a permission errorThe service account is missing BigQuery Job User, which is needed to run query jobs in the billing projectGrant BigQuery Job User in the project that runs the queries, then rerun the question
Connection test fails after the key was rotatedThe Metabase connection still holds the deleted key, or the new key belongs to a different service accountUpload the new JSON key to the database settings and confirm the service account email matches the roles you granted
Key cannot be downloaded againGoogle allows the JSON key to be downloaded only once, so a lost file cannot be recoveredCreate a new key or a new service account with the same three roles, then update Metabase and delete the old key
Expected datasets are missing from the pickerThe sync scope or the project in the connection does not include those datasets, or the roles were granted on a different projectCheck the project ID in the connection, widen the sync scope in the database settings, and review IAM bindings at dataset level
Cross-project routing does not workDatabase routing with BigQuery only routes between databases in different projects, so same-project or unrelated connections are not eligibleConfirm each routed connection points to a separate project, and review the Metabase database routing documentation before relying on it

Questions teams ask before connecting BigQuery

How much work does connecting Metabase to BigQuery take an in-house team?

The connection itself is a short configuration task, but the effort grows with the number of Google Cloud projects, datasets, Metabase groups and people who will hold or rotate the key. A single project with one dataset and one group is a small job. Multiple projects add IAM bindings in each one, and each project may need its own service account if you want clear boundaries. Key governance adds work too: where the JSON file is stored, who can read it, how it is rotated and how the team records who created it. Ask any partner for a written scope that lists the projects, datasets, groups and key handling it covers, since those four items drive the quote more than the connection screen does.

Is a BigQuery service account safer than connecting with a personal login?

A service account is a non-human identity, so it is not tied to one employee's account, which keeps the connection working when someone changes roles or leaves. The trade-off is that the JSON key is a long-lived credential. Anyone who copies it can use it until the key is deleted, and it does not prompt for multi-factor authentication the way a person would. A personal login gives you per-user audit trails in Google Cloud but breaks when that person leaves and makes shared dashboards depend on one account. Most teams reduce the risk by granting only the three roles Metabase needs, limiting who can read the key file and reviewing the service account's activity in Google Cloud logs. Confirm the approach with your security team before you pick one.

What happens if the BigQuery JSON key is deleted?

Metabase stops being able to query BigQuery through that connection, and dashboards and alerts that depend on it fail until a replacement is in place. Google only lets you download the JSON key once, so you cannot recover the original file from Google Cloud. You need either a new key for the same service account or a new service account with the same three roles: BigQuery Data Viewer, BigQuery Metadata Viewer and BigQuery Job User. Then update the database connection in Metabase with the new key. Plan this before an incident by recording which service account the connection uses and keeping the key in a secrets store with a documented rotation step.

Does connecting Metabase to BigQuery require a paid plan?

No. Connecting a BigQuery database works on the Open Source edition, and the connection does not depend on a paid plan. What changes with plan level is how people sign in and what they can see. According to Metabase's pricing page, SSO, row and column level permissions, multi-tenant data segregation and usage analytics and auditing are included only in the Pro and Enterprise plans. If your governance model depends on limiting which rows or columns a group sees, or on signing people in through your identity provider, budget for a paid plan and confirm current prices on the Metabase pricing page before you commit.

What does the work need from our own team?

The engagement needs three named roles from your side. A project owner in each Google Cloud project approves which datasets Metabase may read and the service account that will read them. An IAM administrator grants the three roles and records the bindings. A named Metabase admin decides which groups get which data permissions, owns the connection settings and receives the key handover. Your team should also confirm where the JSON key will be stored on the self-hosted server, who can read that location and how changes are approved. Without these owners, the connection can be built but no one can make the access decisions that follow.

Which datasets should we sync from BigQuery into Metabase?

Sync only the datasets that people need for the questions and dashboards you plan to publish. Each dataset that is synced adds metadata scanning and, depending on your schedule, query activity against BigQuery, which has cost implications in your Google Cloud billing. Start with a short list agreed by the data owners, document why each dataset is included, and exclude raw staging or personally identifiable tables unless a named owner approves them. Revisit the list when new projects or datasets are created, because the service account only sees what its roles and dataset grants allow.

Can Metabase use database routing to separate BigQuery projects?

Partly. Metabase's database routing feature routes between databases in different projects, but it does not separate datasets inside one project. If different groups need different slices of data in the same BigQuery project, you will need dataset-level design choices and Metabase permissions instead. Confirm how routing applies to your layout with the database routing documentation before you design access, since the answer changes which projects you should create or keep together.

How the Metabase server reaches BigQuery

The flow starts with an admin adding the BigQuery connection in Metabase, which uses the service account JSON key stored on the Metabase host. Metabase calls Google APIs to read table metadata and submit query jobs, and BigQuery returns results to the server. End users only ever reach Metabase, never the key or Google. Check that the key store sits inside the trust boundary and that the service account holds only the three roles the connection needs.

Metabase authenticates to Google with a key stored on its own host.

How DeployOpen works on this

DeployOpen plans the BigQuery connection as part of the Metabase deployment inside your own Google Cloud projects and infrastructure. We agree the projects, datasets, service account roles and key handling in writing before any build work starts, so access is reviewed before it is granted.

How we scope

  • Inventory the Google Cloud projects and BigQuery datasets Metabase should sync, and record which ones stay out of scope.
  • Define the service account, its three required roles and the owner who approves changes to them.
  • Agree in writing how the JSON key is stored, rotated, replaced and who can access the Metabase server.

How we build

  • Create the service account and grant the Data Viewer, Metadata Viewer and Job User roles at the scope you approve.
  • Configure the BigQuery connection in Metabase, limit dataset sync, and test queries against each approved dataset.
  • Plan database routing across projects only where your access design needs it, and test that users see only permitted data.

How we hand over

  • Document the service account, role grants, dataset list, key location and the steps to replace the key.
  • Deliver a verification record showing the connection, sync results and permission tests you can review.
  • Walk your security and data teams through the setup and the recovery steps if the key is deleted or leaked.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, key rotation reviews and changes to datasets can be covered under a retainer.
  • Confirm with your Google Cloud administrators which key and role policies apply in your organization before the work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.