Skip to content

Metabase

Metabase collections, dashboards, questions, models, lineage, permissions, subscriptions and usage as SQL tables

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/metabase/index.md to help me query Metabase with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find your most-viewed dashboards

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT title, folder_path, owner, view_count
FROM metabase.main.dashboards
WHERE NOT archived
ORDER BY view_count DESC
LIMIT 10

Quick start

Choose where to run Metabase, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'metabase' AS metabase (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-metabase'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

metabase credentials

Metabase site URL plus an API key, or a username / password for a session login

Get these credentials β†’
secret.sql
CREATE SECRET metabase (
    TYPE metabase,
    base_url  '<base_url>',
    api_key   '<METABASE_API_KEY>',  -- secret
    username  '<username>',
    password  '<METABASE_PASSWORD>',  -- secret
    page_size '<page_size>'
);
Credential fields and requirements β†’

4. Run a query

query.sql
SELECT title, folder_path, owner, view_count
FROM metabase.main.dashboards
WHERE NOT archived
ORDER BY view_count DESC
LIMIT 10
More example queries β†’
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'metabase' AS metabase (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Metabase metadata and usage as SQL: collections, dashboards, questions, models, metrics, queries, lineage, databases, users, permissions, subscriptions, alerts and usage, read-only.

Catalog

Everything metabase exposes once attached β€” read straight from the worker's released build.

metabase 1 schema
main 21 tables Β· 1 function

Metabase content, lineage, data model, admin, delivery and usage.

Schema examples (12)
Examples (12)

Profile the columns of card 40

SUMMARIZE SELECT * FROM metabase.main.run_card('40');

Run a native SQL question with a variable and profile the result

SUMMARIZE SELECT *
FROM metabase.main.run_card('41', parameters := '{"category": "Gizmo"}');

The collection tree, deepest paths last

SELECT folder_path, title, is_personal
FROM metabase.main.folders
WHERE NOT archived
ORDER BY length(folder_path), folder_path;

Content per collection

SELECT f.folder_path, count(c.id) AS charts
FROM metabase.main.folders f
LEFT JOIN metabase.main.charts c ON c.folder_id = f.id
GROUP BY f.folder_path
ORDER BY charts DESC;
8 more examples

Most-viewed dashboards with their collection path

SELECT title, folder_path, owner, view_count
FROM metabase.main.dashboards
WHERE NOT archived
ORDER BY view_count DESC
LIMIT 10;

Dashboards nobody has opened in 90 days

SELECT id, title, owner, last_viewed_at
FROM metabase.main.dashboards
WHERE last_viewed_at < now() - INTERVAL 90 DAY
ORDER BY last_viewed_at;

Cards per dashboard tab

SELECT dashboard_title, tab_name, count(*) AS cards,
  count(card_id) AS questions
FROM metabase.main.dashboard_cards
GROUP BY ALL
ORDER BY dashboard_title, tab_name;

Which dashboard filters drive which card

SELECT d.card_title, m.parameter_id, m.target
FROM metabase.main.dashboard_cards d,
     unnest(d.parameter_mappings) AS t(m)
WHERE d.dashboard_id = '2'
ORDER BY d.card_title;

Dashboards with the most tabs

SELECT dashboard_title, count(*) AS tabs, sum(card_count) AS cards
FROM metabase.main.dashboard_tabs
GROUP BY dashboard_title
ORDER BY tabs DESC;

Cards by type and query kind

SELECT card_type, query_type, count(*) AS cards
FROM metabase.main.charts
WHERE NOT archived
GROUP BY ALL
ORDER BY cards DESC;

Most-viewed models

SELECT title, folder_path, view_count
FROM metabase.main.charts
WHERE card_type = 'model'
ORDER BY view_count DESC
LIMIT 10;

Native SQL questions that select from ORDERS

SELECT id, title, native_sql
FROM metabase.main.queries
WHERE query_type = 'native' AND native_sql ILIKE '%orders%'
ORDER BY id;
Tables
alerts 1 example19 cols

Question alerts (notify when a question returns rows or crosses a goal); recipients reduced to counts and domains.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Alert (notification) id.
card_id VARCHAR
Question the alert watches.
card_title VARCHAR
Name of the question (when Metabase includes it).
send_condition VARCHAR
has_result, goal_above or goal_below.
send_once BOOLEAN
Whether the alert fires only once.
active BOOLEAN
Whether the alert is active.
owner VARCHAR
Display name of the user who created the object.
owner_id VARCHAR
Id of the creator.
created_at TIMESTAMP WITH TIME ZONE
When the alert was created.
updated_at TIMESTAMP WITH TIME ZONE
When it was last updated.
cron_schedules VARCHAR[]
Schedules: Quartz cron expressions (0.54+) or 'daily 9h' for legacy alerts.
channel_types VARCHAR[]
Delivery channels (email, slack, http).
recipient_count BIGINT
Number of recipients (users, groups and external addresses).
user_recipient_count BIGINT
Count of recipients who are Metabase users.
group_recipient_count BIGINT
Count of recipients that are whole permission groups.
external_recipient_count BIGINT
Raw email addresses (or other raw values).
recipient_domains VARCHAR[]
Distinct email domains of the recipients.
url VARCHAR
Web UI link to the question.
ConstraintsPRIMARY KEY (id)
Example

Active alerts and who receives them

SELECT card_title, send_condition, cron_schedules, recipient_count,
  recipient_domains
FROM metabase.main.alerts
WHERE active
ORDER BY card_title;
Link
card_tables 2 examples14 cols

Lineage: the database tables (and source cards) each MBQL card reads, with schema and table names.

Columns
card_id VARCHAR
Id of the question, model or metric whose query reads this source.
card_title VARCHAR
Card name.
card_type VARCHAR
Card type: question, model or metric.
role VARCHAR
'source' (the stage's main source) or 'join'.
join_alias VARCHAR
Alias of the join (NULL for the main source).
stage INTEGER
Index (from 0) of the query stage the source belongs to.
table_id VARCHAR
Id of the table read (NULL when the source is a card).
source_card_id VARCHAR
Id of the card read (NULL when the source is a table).
database_id VARCHAR
Database of the card.
database_name VARCHAR
Name of that database in Metabase.
table_schema VARCHAR
Schema of the table read.
table_name VARCHAR
Name of the table read.
table_display_name VARCHAR
Display name of the table read.
archived BOOLEAN
Whether the card is in the trash.
Examples (2)

Which warehouse tables feed each dashboard

SELECT DISTINCT d.dashboard_title, t.table_schema, t.table_name
FROM metabase.main.dashboard_cards d
JOIN metabase.main.card_tables t ON t.card_id = d.card_id
ORDER BY ALL;

Most-used tables across MBQL questions

SELECT table_name, count(DISTINCT card_id) AS cards
FROM metabase.main.card_tables
WHERE table_id IS NOT NULL
GROUP BY table_name
ORDER BY cards DESC;
Link
charts 2 examples27 cols

Saved questions, models and metrics (cards) with collection path, creator, usage and query kind.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Card id.
title VARCHAR
Card name.
description VARCHAR
Card description.
card_type VARCHAR
Card type: question, model or metric.
display VARCHAR
Visualization type, e.g. bar, line, table, scalar.
query_type VARCHAR
'native' (SQL) or 'query' (MBQL / query builder).
database_id VARCHAR
Id of the database the card queries.
table_id VARCHAR
Id of the main source table (MBQL cards).
source_card_id VARCHAR
Id of the card (often a model) this card is built on.
folder_id VARCHAR
Id of the collection holding the object (NULL = root collection).
folder_path VARCHAR
Slash-separated collection path from the root ('Our analytics' is '/'), e.g. /Marketing/EMEA.
owner VARCHAR
Display name of the user who created the object.
owner_id VARCHAR
Id of the user who created the card.
created_at TIMESTAMP WITH TIME ZONE
When the card was created.
updated_at TIMESTAMP WITH TIME ZONE
When the card was last updated.
last_viewed_at TIMESTAMP WITH TIME ZONE
Last time the card ran (Metabase's last_used_at; there is no separate last-view time).
last_used_at TIMESTAMP WITH TIME ZONE
Last time the card's query ran (Metabase 0.50+).
view_count BIGINT
Count of lifetime views Metabase has recorded for the card.
url VARCHAR
Web UI link to the question, model or metric.
archived BOOLEAN
Whether the card is in the trash.
dashboard_id VARCHAR
Dashboard the question is saved in (dashboard questions, Metabase 0.53+).
collection_position INTEGER
Pinned position in its collection (NULL = not pinned).
is_public BOOLEAN
Whether the card has a public sharing link (the link itself is not returned).
enable_embedding BOOLEAN
Whether static embedding is enabled.
cache_ttl INTEGER
Cache TTL override in hours (NULL = default).
entity_id VARCHAR
Stable entity id used by serialization.
ConstraintsPRIMARY KEY (id)
Examples (2)

Cards by type and query kind

SELECT card_type, query_type, count(*) AS cards
FROM metabase.main.charts
WHERE NOT archived
GROUP BY ALL
ORDER BY cards DESC;

Most-viewed models

SELECT title, folder_path, view_count
FROM metabase.main.charts
WHERE card_type = 'model'
ORDER BY view_count DESC
LIMIT 10;
Link
connections 1 example23 cols

Connected databases: engine, host, port and database name β€” never passwords, keys or other connection secrets.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Database id.
title VARCHAR
Database name in Metabase.
created_at TIMESTAMP WITH TIME ZONE
When the connection was added.
updated_at TIMESTAMP WITH TIME ZONE
When the connection was last updated.
url VARCHAR
Admin UI link to the connection.
engine VARCHAR
Driver: postgres, mysql, bigquery-cloud-sdk, snowflake, redshift, h2, sqlite …
host VARCHAR
Server host name (no credentials).
port INTEGER
TCP port number of the database server.
db_name VARCHAR
Database / catalog / project name, with inline credentials and options stripped.
description VARCHAR
Free-text note an admin wrote about the connection.
timezone VARCHAR
Database timezone Metabase detected.
is_sample BOOLEAN
Whether this is Metabase's Sample Database.
is_audit BOOLEAN
Whether this is the internal Usage Analytics database (Pro/Enterprise).
is_full_sync BOOLEAN
Whether field values are fully synced.
is_on_demand BOOLEAN
Whether field values are synced on demand.
auto_run_queries BOOLEAN
Whether queries run automatically in the query builder.
initial_sync_status VARCHAR
Initial sync status: incomplete, complete, aborted.
metadata_sync_schedule VARCHAR
Quartz cron of the metadata sync.
cache_field_values_schedule VARCHAR
Quartz cron of the field-values scan.
uploads_enabled BOOLEAN
Whether CSV uploads go to this database.
dbms_version JSON
Database server flavor and version as reported by the driver.
creator_id VARCHAR
Id of the user who added the connection.
ConstraintsPRIMARY KEY (id)
Example

Connections by engine

SELECT engine, count(*) AS databases, list(title ORDER BY title) AS names
FROM metabase.main.connections
GROUP BY engine
ORDER BY databases DESC;
Link
content_usage 2 examples10 cols

Views per dashboard and card: per day from Usage Analytics (Pro/Enterprise), else Metabase's lifetime counters (OSS).

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
content_type VARCHAR
'dashboard' or 'card' (Usage Analytics may also report table / collection views).
content_id VARCHAR
Dashboard or card id.
title VARCHAR
Dashboard or card name.
view_date DATE
UTC day of the views (NULL for OSS lifetime counters).
view_count BIGINT
Views that day (Usage Analytics) or lifetime views (OSS).
user_count BIGINT
Distinct viewers that day (Usage Analytics only).
last_viewed_at TIMESTAMP WITH TIME ZONE
Latest view in the row's day, or the last view / run ever (OSS).
usage_source VARCHAR
'usage_analytics' (View log) or 'lifetime_counters' (OSS counters).
url VARCHAR
Web UI link to the content.
Examples (2)

Most-viewed dashboards (per-day rows on Pro/Enterprise are summed)

SELECT content_id, title, sum(view_count) AS views
FROM metabase.main.content_usage
WHERE content_type = 'dashboard'
GROUP BY ALL
ORDER BY views DESC
LIMIT 10;

Daily views for one week (Usage Analytics only)

SELECT view_date, sum(view_count) AS views, max(user_count) AS peak_viewers
FROM metabase.main.content_usage
WHERE view_date >= DATE '2026-11-01' AND view_date < DATE '2026-11-08'
GROUP BY ALL
ORDER BY view_date;
Link
dashboard_cards 2 examples20 cols

Cards placed on dashboards (questions and text/heading/link cards) with tab, position and filter wiring.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Dashboard card (dashcard) id.
dashboard_id VARCHAR
Id of the dashboard.
dashboard_title VARCHAR
Name of the dashboard.
tab_id VARCHAR
Id of the dashboard tab the card is on (NULL when the dashboard has no tabs).
tab_name VARCHAR
Name of the dashboard tab.
card_id VARCHAR
Id of the question / model / metric shown (NULL for virtual cards).
card_title VARCHAR
Name of the card shown.
card_type VARCHAR
Card type: question, model or metric.
display VARCHAR
Visualization: bar, line, table, scalar … or text / heading / link for virtual cards.
is_virtual BOOLEAN
Whether this is a text, heading, link or iframe card with no question.
text VARCHAR
Markdown of a text or heading card.
row INTEGER
Grid row (top edge).
col INTEGER
Grid column (left edge).
size_x INTEGER
Width in grid columns.
size_y INTEGER
Height in grid rows.
series_card_ids VARCHAR[]
Ids of extra cards combined into this card as series.
parameter_mappings STRUCT of 3 fields[]
Dashboard filters wired to this card: parameter_id, card_id and the target (field or template tag) as JSON.
STRUCT[] 3 fields
  • parameter_idVARCHAR
  • card_idBIGINT
  • targetVARCHAR
action_id VARCHAR
Id of the action of an action button, if any.
url VARCHAR
Web UI link to the dashboard (and tab).
ConstraintsPRIMARY KEY (id)
Examples (2)

Cards per dashboard tab

SELECT dashboard_title, tab_name, count(*) AS cards,
  count(card_id) AS questions
FROM metabase.main.dashboard_cards
GROUP BY ALL
ORDER BY dashboard_title, tab_name;

Which dashboard filters drive which card

SELECT d.card_title, m.parameter_id, m.target
FROM metabase.main.dashboard_cards d,
     unnest(d.parameter_mappings) AS t(m)
WHERE d.dashboard_id = '2'
ORDER BY d.card_title;
Link
dashboard_tabs 1 example10 cols

Dashboard tabs with their position and card count.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Dashboard tab id.
dashboard_id VARCHAR
Id of the dashboard.
dashboard_title VARCHAR
Name of the dashboard.
title VARCHAR
Tab name.
position INTEGER
Index (from 0) of the tab, left to right.
card_count BIGINT
Number of cards on the tab.
created_at TIMESTAMP WITH TIME ZONE
When the tab was created.
updated_at TIMESTAMP WITH TIME ZONE
When the tab was last updated.
url VARCHAR
Web UI link to the tab.
ConstraintsPRIMARY KEY (id)
Example

Dashboards with the most tabs

SELECT dashboard_title, count(*) AS tabs, sum(card_count) AS cards
FROM metabase.main.dashboard_tabs
GROUP BY dashboard_title
ORDER BY tabs DESC;
Link
dashboards 2 examples22 cols

Metabase dashboards with collection path, creator, view counts and filter parameters.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Dashboard id.
title VARCHAR
Dashboard name.
description VARCHAR
Dashboard description.
folder_id VARCHAR
Id of the collection holding the object (NULL = root collection).
folder_path VARCHAR
Slash-separated collection path from the root ('Our analytics' is '/'), e.g. /Marketing/EMEA.
owner VARCHAR
Display name of the user who created the object.
owner_id VARCHAR
Id of the user who created the dashboard.
created_at TIMESTAMP WITH TIME ZONE
When the dashboard was created.
updated_at TIMESTAMP WITH TIME ZONE
When the dashboard was last updated.
last_viewed_at TIMESTAMP WITH TIME ZONE
When the dashboard was last viewed.
view_count BIGINT
Count of lifetime views Metabase has recorded for the dashboard.
url VARCHAR
Web UI link to the dashboard.
archived BOOLEAN
Whether the dashboard is in the trash.
collection_position INTEGER
Pinned position in its collection (NULL = not pinned).
is_public BOOLEAN
Whether the dashboard has a public sharing link (the link itself is not returned).
enable_embedding BOOLEAN
Whether static embedding is enabled.
auto_apply_filters BOOLEAN
Whether filter changes apply immediately.
width VARCHAR
Layout width: fixed or full.
cache_ttl INTEGER
Cache TTL override in hours (NULL = default).
entity_id VARCHAR
Stable entity id used by serialization.
parameters STRUCT of 6 fields[]
Dashboard filters: id, name, slug, type, default value (JSON) and required.
STRUCT[] 6 fields
  • idVARCHAR
  • nameVARCHAR
  • slugVARCHAR
  • typeVARCHAR
  • default_valueVARCHAR
  • requiredBOOLEAN
ConstraintsPRIMARY KEY (id)
Examples (2)

Most-viewed dashboards with their collection path

SELECT title, folder_path, owner, view_count
FROM metabase.main.dashboards
WHERE NOT archived
ORDER BY view_count DESC
LIMIT 10;

Dashboards nobody has opened in 90 days

SELECT id, title, owner, last_viewed_at
FROM metabase.main.dashboards
WHERE last_viewed_at < now() - INTERVAL 90 DAY
ORDER BY last_viewed_at;
Link
fields 2 examples23 cols

Columns of every synced table with base, effective and semantic types and foreign keys.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Field id.
table_id VARCHAR
Id of the table the field belongs to (join tables.id).
table_name VARCHAR
Name of that table in the database.
table_schema VARCHAR
Schema of that table (empty for schemaless databases).
database_id VARCHAR
Id of the connected database (join connections.id).
name VARCHAR
Column name in the database.
display_name VARCHAR
Display name in Metabase.
description VARCHAR
Curated description.
base_type VARCHAR
Metabase base type, e.g. type/Integer, type/Text, type/DateTime.
effective_type VARCHAR
Effective type after coercion.
semantic_type VARCHAR
Semantic type, e.g. type/PK, type/FK, type/Email, type/Category.
database_type VARCHAR
Native database column type.
is_pk BOOLEAN
Whether the field is the table's primary key (semantic type type/PK).
fk_target_field_id VARCHAR
Field this foreign key points at.
fk_target_table_id VARCHAR
Table of the foreign key target.
fk_target_field_name VARCHAR
Name of the foreign key target field.
position INTEGER
Ordinal position of the column in its table, counted from 0.
visibility_type VARCHAR
normal, details-only, sensitive, hidden or retired.
active BOOLEAN
Whether the column still exists.
has_field_values VARCHAR
Filter widget source: list, search, auto-list or none.
coercion_strategy VARCHAR
Type coercion applied, e.g. Coercion/UNIXSeconds->DateTime.
parent_id VARCHAR
Parent field of a nested (JSON-unfolded) field.
ConstraintsPRIMARY KEY (id)
Examples (2)

Foreign keys between tables

SELECT table_name, name, fk_target_field_name
FROM metabase.main.fields
WHERE semantic_type = 'type/FK'
ORDER BY table_name, name;

Columns per semantic type in one database

SELECT semantic_type, count(*) AS fields
FROM metabase.main.fields
WHERE database_id = '1'
GROUP BY semantic_type
ORDER BY fields DESC;
Link
folders 2 examples18 cols

Metabase collections (the folder tree) with full paths, personal owners and archive state.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Collection id.
title VARCHAR
Collection name.
folder_path VARCHAR
Slash-separated collection path from the root ('Our analytics' is '/'), e.g. /Marketing/EMEA.
parent_id VARCHAR
Id of the parent collection (NULL = root).
owner VARCHAR
Display name of the user who created the object.
owner_id VARCHAR
Id of the user whose personal collection this is (NULL for shared collections).
created_at TIMESTAMP WITH TIME ZONE
When the collection was created.
url VARCHAR
Web UI link to the collection.
description VARCHAR
Collection description.
slug VARCHAR
URL slug.
location VARCHAR
Ancestor collection ids, e.g. '/8/'.
is_personal BOOLEAN
Whether this is (inside) a personal collection.
archived BOOLEAN
Whether the collection is in the trash.
namespace VARCHAR
Collection namespace (NULL for regular collections; e.g. 'snippets').
collection_type VARCHAR
Special type: 'instance-analytics' (Usage Analytics), 'trash', or NULL.
authority_level VARCHAR
'official' for official collections (Pro/Enterprise), else NULL.
entity_id VARCHAR
Stable entity id used by serialization.
ConstraintsPRIMARY KEY (id)
Examples (2)

The collection tree, deepest paths last

SELECT folder_path, title, is_personal
FROM metabase.main.folders
WHERE NOT archived
ORDER BY length(folder_path), folder_path;

Content per collection

SELECT f.folder_path, count(c.id) AS charts
FROM metabase.main.folders f
LEFT JOIN metabase.main.charts c ON c.folder_id = f.id
GROUP BY f.folder_path
ORDER BY charts DESC;
Link
group_permissions 1 example10 cols

Data permissions summary: what each group may view, query, download and curate per database.

Columns
group_idnot null VARCHAR
Id of the permission group (join groups.id).
group_name VARCHAR
Name of the permission group (NULL for groups the API hides).
database_idnot null VARCHAR
Id of the connected database (join connections.id).
database_name VARCHAR
Name of that database in Metabase.
view_data VARCHAR
View-data level (unrestricted, blocked, sandboxed, impersonated …).
create_queries VARCHAR
Query level: query-builder-and-native, query-builder, no, or granular.
download VARCHAR
Download level: full, limited, none, or granular.
data_model VARCHAR
Data-model curation rights (all, none, or granular).
details VARCHAR
Whether the group may edit the connection details (yes / no).
permissions JSON
The full grant for this group and database as JSON.
ConstraintsPRIMARY KEY (group_id, database_id)
Example

Groups that can write native SQL, per database

SELECT group_name, database_name
FROM metabase.main.group_permissions
WHERE create_queries = 'query-builder-and-native'
ORDER BY ALL;
Link
groups 1 example7 cols

Permission groups with member counts.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Group id.
title VARCHAR
Name of the permission group (NULL for groups the API hides).
member_count BIGINT
Number of members.
magic_group_type VARCHAR
'admin', 'all-internal-users' or NULL for custom groups.
is_tenant_group BOOLEAN
Whether the group belongs to a tenant (multi-tenant embedding).
entity_id VARCHAR
Stable entity id.
ConstraintsPRIMARY KEY (id)
Example

Groups by size

SELECT title, member_count
FROM metabase.main.groups
ORDER BY member_count DESC;
Link
instance 1 example11 cols

The Metabase instance: version, edition (OSS or Pro/Enterprise), Cloud hosting and Usage Analytics availability.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
urlnot null VARCHAR
The site's base URL (from the secret).
version VARCHAR
Version tag, e.g. v0.65.4 (OSS) or v1.65.4 (Pro/Enterprise).
edition VARCHAR
'oss' or 'enterprise' (Pro and Enterprise).
is_hosted BOOLEAN
Whether this is Metabase Cloud.
usage_analytics BOOLEAN
Whether Usage Analytics (audit_app) is licensed and enabled.
site_name VARCHAR
Name the admin gave the Metabase site (shown in the UI and emails).
site_url VARCHAR
Configured site URL.
site_locale VARCHAR
Default locale.
report_timezone VARCHAR
Report timezone (NULL = database timezone).
enabled_features VARCHAR[]
Licensed token features that are on.
ConstraintsPRIMARY KEY (url)
Example

Which usage source content_usage will use

SELECT version, edition, usage_analytics FROM metabase.main.instance;
Link
queries 2 examples16 cols

The query behind each card: native SQL text or MBQL, database, source tables and template tags.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Card id (a card holds exactly one query).
card_id VARCHAR
Card id (same as id).
title VARCHAR
Card name.
card_type VARCHAR
Card type: question, model or metric.
url VARCHAR
Web UI link to the card.
query_type VARCHAR
'native' (SQL) or 'query' (MBQL).
database_id VARCHAR
Database the query runs against.
table_id VARCHAR
Main source table (MBQL).
native_sql VARCHAR
SQL text of a native question (NULL for MBQL).
template_tags STRUCT of 6 fields[]
Variables of a native question: name, id, type, display name, default (JSON), required.
STRUCT[] 6 fields
  • nameVARCHAR
  • idVARCHAR
  • typeVARCHAR
  • display_nameVARCHAR
  • default_valueVARCHAR
  • requiredBOOLEAN
source_table_ids VARCHAR[]
Ids of every table the MBQL query reads (main source and joins).
source_card_ids VARCHAR[]
Ids of every card (model / question) the MBQL query reads.
mbql_format VARCHAR
'pmbql' (MBQL 5 stages, Metabase 0.57+) or 'legacy'.
dataset_query JSON
The full query definition as JSON.
archived BOOLEAN
Whether the card is in the trash.
ConstraintsPRIMARY KEY (id)
Examples (2)

Native SQL questions that select from ORDERS

SELECT id, title, native_sql
FROM metabase.main.queries
WHERE query_type = 'native' AND native_sql ILIKE '%orders%'
ORDER BY id;

Questions built on another card (model reuse)

SELECT q.title, src AS source_card_id
FROM metabase.main.queries q,
     unnest(q.source_card_ids) AS t(src)
ORDER BY q.title;
Link
query_history 2 examples15 cols

Every query Metabase ran β€” runtime, rows, source, error, cache hit β€” from the Usage Analytics Query log (Pro/Enterprise).

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
execution_idnot null VARCHAR
Query execution id.
created_at TIMESTAMP WITH TIME ZONE
When the query started.
runtime_seconds DOUBLE
Runtime in seconds.
result_rows BIGINT
Count of rows the query returned.
status VARCHAR
'complete' or 'error'.
message VARCHAR
Error text (NULL on success).
source VARCHAR
Where the query came from: dashboard, question, ad-hoc, pulse, csv-download …
is_native BOOLEAN
Whether the query was native SQL.
cache_hit BOOLEAN
Whether the result came from the cache.
card_id VARCHAR
Card that ran it, if any.
dashboard_id VARCHAR
Dashboard that ran it, if any.
database_id VARCHAR
Database queried.
user_id VARCHAR
User who ran it.
url VARCHAR
Web UI link to the card, if any.
ConstraintsPRIMARY KEY (execution_id)
Examples (2)

Slowest questions over the last 7 days

SELECT card_id, count(*) AS runs, avg(runtime_seconds) AS avg_s,
  max(runtime_seconds) AS max_s
FROM metabase.main.query_history
WHERE card_id IS NOT NULL AND NOT cache_hit
GROUP BY card_id
ORDER BY avg_s DESC
LIMIT 10;

Errors by source in a fixed window

SELECT source, count(*) AS errors
FROM metabase.main.query_history
WHERE status = 'error' AND created_at >= TIMESTAMPTZ '2026-11-01' AND created_at < TIMESTAMPTZ '2026-11-08'
GROUP BY ALL
ORDER BY errors DESC;
Link
recent_views 1 example10 cols

What the authenticating user viewed recently (questions, models, dashboards, collections, tables).

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
modelnot null VARCHAR
Item kind: card, dataset (model), metric, dashboard, collection or table.
idnot null VARCHAR
Item id.
title VARCHAR
Item name.
viewed_at TIMESTAMP WITH TIME ZONE
When it was viewed.
folder_id VARCHAR
Collection holding the item (NULL / 'root' = root).
folder_name VARCHAR
Name of that collection.
database_id VARCHAR
Database (cards and tables).
display VARCHAR
Visualization (cards).
url VARCHAR
Web UI link to the item.
ConstraintsPRIMARY KEY (model, id)
Example

My recently viewed dashboards

SELECT title, viewed_at
FROM metabase.main.recent_views
WHERE model = 'dashboard'
ORDER BY viewed_at DESC;
Link
revisions 2 examples14 cols

Revision history of dashboards, cards and segments: who changed what, and when.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
entity_typenot null VARCHAR
Kind of object: dashboard, card or segment.
entity_idnot null VARCHAR
Id of the object.
idnot null VARCHAR
Revision id.
changed_at TIMESTAMP WITH TIME ZONE
When the change was made.
user_id VARCHAR
Id of the user who made the change.
user_name VARCHAR
Name of the user who made the change.
description VARCHAR
Summary of the change, e.g. 'renamed this'.
message VARCHAR
Optional revision message.
is_creation BOOLEAN
Whether this revision created the object.
is_reversion BOOLEAN
Whether this revision reverted to an earlier one.
has_multiple_changes BOOLEAN
Whether several properties changed at once.
diff JSON
Before / after values of the changed properties.
metabase_version VARCHAR
Metabase version that recorded the revision.
ConstraintsPRIMARY KEY (entity_type, entity_id, id)
Examples (2)

Most-edited dashboards

SELECT entity_id, count(*) AS edits, max(changed_at) AS last_edit
FROM metabase.main.revisions
WHERE entity_type = 'dashboard'
GROUP BY entity_id
ORDER BY edits DESC;

History of one question

SELECT changed_at, user_name, description
FROM metabase.main.revisions
WHERE entity_type = 'card' AND entity_id = '41'
ORDER BY changed_at;
Link
segments 1 example15 cols

Segments: saved, named filters on a table.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Segment id.
title VARCHAR
Segment name.
description VARCHAR
Free-text explanation of what the segment selects.
table_id VARCHAR
Table the segment filters.
database_id VARCHAR
Database of the table.
definition_description VARCHAR
Human-readable form of the filter.
definition JSON
The filter definition (MBQL) as JSON.
archived BOOLEAN
Whether the segment is retired.
owner VARCHAR
Display name of the user who created the object.
owner_id VARCHAR
Id of the creator.
created_at TIMESTAMP WITH TIME ZONE
When the segment was created.
updated_at TIMESTAMP WITH TIME ZONE
When the segment was last updated.
url VARCHAR
Link to the segment in the data reference.
entity_id VARCHAR
Stable entity id used by serialization.
ConstraintsPRIMARY KEY (id)
Example

Segments per table

SELECT s.title, s.definition_description, t.table_name
FROM metabase.main.segments s
JOIN metabase.main.tables t ON t.id = s.table_id
ORDER BY s.title;
Link
subscriptions 1 example19 cols

Dashboard subscriptions (scheduled email / Slack deliveries); recipients reduced to counts and domains.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Subscription (pulse) id.
title VARCHAR
Subscription name (usually the dashboard name).
dashboard_id VARCHAR
Dashboard delivered.
folder_id VARCHAR
Id of the collection holding the object (NULL = root collection).
owner VARCHAR
Display name of the user who created the object.
owner_id VARCHAR
Id of the creator.
created_at TIMESTAMP WITH TIME ZONE
When the subscription was created.
updated_at TIMESTAMP WITH TIME ZONE
When it was last updated.
archived BOOLEAN
Whether the subscription is archived.
skip_if_empty BOOLEAN
Skip delivery when every card is empty.
card_ids VARCHAR[]
Cards included in the delivery.
channel_types VARCHAR[]
Delivery channels (email, slack, http).
schedules STRUCT of 6 fields[]
Schedule per channel: type, day, hour, frame and whether it is enabled.
STRUCT[] 6 fields
  • channel_typeVARCHAR
  • schedule_typeVARCHAR
  • schedule_dayVARCHAR
  • schedule_hourBIGINT
  • schedule_frameVARCHAR
  • enabledBOOLEAN
recipient_count BIGINT
Number of recipients across channels (users, groups and external addresses).
user_recipient_count BIGINT
Count of recipients who are Metabase users.
external_recipient_count BIGINT
Recipients given as raw email addresses (or other raw values).
recipient_domains VARCHAR[]
Distinct email domains of the recipients (addresses are never returned).
url VARCHAR
Web UI link to the dashboard.
ConstraintsPRIMARY KEY (id)
Example

Subscriptions that send outside the company domain

SELECT title, recipient_domains
FROM metabase.main.subscriptions
WHERE NOT archived AND len(list_filter(recipient_domains, lambda d: d <> 'example.com')) > 0
ORDER BY title;
Link
tables 1 example18 cols

Tables Metabase has synced, with schema, visibility, entity type and estimated row counts.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
Table id.
database_id VARCHAR
Id of the connected database (join connections.id).
database_name VARCHAR
Name of that database in Metabase.
table_schema VARCHAR
Schema (empty or NULL for schemaless databases).
table_name VARCHAR
Table name in the database.
display_name VARCHAR
Display name in Metabase.
description VARCHAR
Curated description.
entity_type VARCHAR
Entity type, e.g. entity/UserTable, entity/TransactionTable.
visibility_type VARCHAR
NULL (visible), hidden, technical or cruft.
active BOOLEAN
Whether the table still exists in the database.
estimated_row_count BIGINT
Row count estimate from the last sync.
view_count BIGINT
Times the table has been viewed in Metabase.
field_order VARCHAR
Column ordering: database, alphabetical, custom or smart.
initial_sync_status VARCHAR
State of the first metadata sync: incomplete, complete or aborted.
created_at TIMESTAMP WITH TIME ZONE
When Metabase first synced the table.
updated_at TIMESTAMP WITH TIME ZONE
When the table's metadata last changed.
url VARCHAR
Link to the table's data in the Metabase UI.
ConstraintsPRIMARY KEY (id)
Example

Largest tables by estimated rows

SELECT database_name, table_schema, table_name, estimated_row_count
FROM metabase.main.tables
WHERE active
ORDER BY estimated_row_count DESC NULLS LAST
LIMIT 10;
Link
users 2 examples16 cols

Metabase users with group memberships, admin flag and last login β€” never credentials.

Columns
tool VARCHAR
The BI tool this row came from: always 'metabase'.
idnot null VARCHAR
User id.
url VARCHAR
Admin UI link to the user.
display_name VARCHAR
Full name (common_name).
email VARCHAR
Email address (the login).
first_name VARCHAR
Given name as entered in Metabase.
last_name VARCHAR
Family name as entered in Metabase.
is_active BOOLEAN
False when the account is deactivated.
is_superuser BOOLEAN
Whether the user is an administrator.
last_login TIMESTAMP WITH TIME ZONE
Last login time.
created_at TIMESTAMP WITH TIME ZONE
When the account was created (date_joined).
updated_at TIMESTAMP WITH TIME ZONE
When the account was last updated.
sso_source VARCHAR
Single sign-on source (google, ldap, saml, jwt) or NULL for password logins.
group_ids VARCHAR[]
Ids of the groups the user belongs to (admins see these).
personal_collection_id VARCHAR
Id of the user's personal collection.
locale VARCHAR
Preferred locale (NULL = site default).
ConstraintsPRIMARY KEY (id)
Examples (2)

Admins and when they last logged in

SELECT display_name, email, last_login
FROM metabase.main.users
WHERE is_superuser AND is_active
ORDER BY last_login DESC NULLS LAST;

Users who never logged in

SELECT email, created_at
FROM metabase.main.users
WHERE is_active AND last_login IS NULL
ORDER BY created_at;
Link
Table functions
run_card (card_id VARCHAR, parameters := VARCHAR) 2 examples

Run a saved question, model or metric (read-only) and return its rows, typed from the card's result metadata.

Positional arguments
card_id VARCHAR
Numeric id of the saved question, model or metric to run; find ids in metabase.main.charts.
Named arguments
parameters := VARCHAR
JSON object of parameter values keyed by the card's parameter slug or a native question's variable name, e.g. '{"category": "Gizmo"}' (default: none, so defaults apply). Β· default "{}"
Returns columns
pending VARCHAR
Placeholder; create a metabase secret to get the real columns
Returns columns Β· depends on the arguments
pending VARCHAR
Placeholder; create a metabase secret to get the real columns
Examples (2)

Profile the columns of card 40

SUMMARIZE SELECT * FROM metabase.main.run_card('40');

Run a native SQL question with a variable and profile the result

SUMMARIZE SELECT *
FROM metabase.main.run_card('41', parameters := '{"category": "Gizmo"}');
Link

Credentials

The secret type metabase declares, as reported by the worker itself.

metabase

How to get these credentials

Metabase site URL plus an API key, or a username / password for a session login

secret.sql
CREATE SECRET metabase (
    TYPE metabase,
    base_url  '<base_url>',
    api_key   '<METABASE_API_KEY>',  -- secret
    username  '<username>',
    password  '<METABASE_PASSWORD>',  -- secret
    page_size '<page_size>'
);
Key Type Required Description
base_url VARCHAR β€” Metabase site URL, e.g. https://acme.metabaseapp.com or https://bi.acme.com (http:// only for 127.0.0.1/localhost).
api_key secret VARCHAR β€” API key (Admin settings > Authentication > API keys), sent as x-api-key. Use this or username + password.
username VARCHAR β€” Login email for a session login (when no api_key).
password secret VARCHAR β€” Password paired with username.
page_size VARCHAR β€” Optional page size for the paged users listing (default 500).

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching metabase β€” the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

dashboards_columns β€” The dashboards columns (binds only; create a metabase secret and drop LIMIT 0 for rows)

SELECT tool, id, title, folder_path, owner, view_count, url
FROM metabase.main.dashboards
LIMIT 0;

Uses dashboards

charts_columns β€” The charts columns (binds only; create a metabase secret and drop LIMIT 0 for rows)

SELECT id, title, card_type, query_type, folder_path
FROM metabase.main.charts
LIMIT 0;

Uses charts

Profile the columns of card 40

SUMMARIZE SELECT * FROM metabase.main.run_card('40')

Uses run_card

The collection tree, deepest paths last

SELECT folder_path, title, is_personal
FROM metabase.main.folders
WHERE NOT archived
ORDER BY length(folder_path), folder_path

Uses folders

Cards per dashboard tab

SELECT dashboard_title, tab_name, count(*) AS cards,
  count(card_id) AS questions
FROM metabase.main.dashboard_cards
GROUP BY ALL
ORDER BY dashboard_title, tab_name

Uses dashboard_cards

Dashboards with the most tabs

SELECT dashboard_title, count(*) AS tabs, sum(card_count) AS cards
FROM metabase.main.dashboard_tabs
GROUP BY dashboard_title
ORDER BY tabs DESC

Uses dashboard_tabs

29 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Which Metabase dashboard has the most views?
  • List the titles of the cards in the /Marketing/EMEA collection.
  • Which saved questions are written in native SQL?
  • Which Metabase cards are models?
  • Which cards are in the trash (archived)?
  • Which Metabase users are deactivated? Give their emails.

Metabase is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.