Metabase
Metabase asks questions through a database connection. It cannot read a bucket or an Iceberg catalog itself, so connect it to the engine that already reads your Send2Bucket data.
| You have | Use |
|---|---|
| Records loaded into PostgreSQL or MySQL | A PostgreSQL or MySQL connection |
| BigQuery | A BigQuery connection |
| Athena, Trino or Starburst over the bucket or Iceberg table | An Athena or Starburst connection |
| ClickHouse, Redshift or Snowflake | That engine's connection |
| MotherDuck, or a DuckDB file | The DuckDB driver |
We ran the PostgreSQL path in Metabase 0.65.6: the connection, a native query for each example question, a native query with a date filter, and a query-builder question on a view. The other connections follow Metabase's documentation and were not run by us.
PostgreSQL or MySQL
Load records on a schedule as in PostgreSQL or MySQL. Metabase then reads the s2b_records table like any other.
-
Create a user that can only read:
CREATE ROLE metabase LOGIN PASSWORD '<password>';GRANT CONNECT ON DATABASE <database> TO metabase;GRANT USAGE ON SCHEMA public TO metabase;GRANT SELECT ON s2b_records TO metabase; -
In Metabase, go to Admin settings > Databases > Add a database, choose PostgreSQL, and fill in host, port, database name, username and password. Turn on Use a secure connection (SSL) for a database outside your network.
-
Under the advanced options, turn off Unfold JSON Columns.
dataandresourcehold differently shaped JSON for each signal, and unfolding them makes every sync scan the table.
Metabase lists data, resource and scope as JSON columns. The query builder cannot reach inside them, so use one of two approaches.
Native queries. Open New > SQL query and paste any query from the PostgreSQL example queries. We ran all four through Metabase's API against the sample data. A [[ ]] block with a variable becomes a filter widget on the question or dashboard:
SELECT data->>'event' AS event, count(*) AS events
FROM s2b_records
WHERE signal = 'event'
[[AND received_at >= {{since}}]]
GROUP BY event
ORDER BY events DESC;
Set the since variable type to Date in the variables sidebar. Without a value, the bracketed condition is left out.
A view with columns. Create a view that pulls out the fields people chart, grant it to the Metabase user, and the query builder treats it as a normal table:
CREATE VIEW s2b_events AS
SELECT received_at,
data->>'event' AS event,
data->>'user_id' AS user_id,
(data->>'cents')::int AS cents
FROM s2b_records
WHERE signal = 'event';
GRANT SELECT ON s2b_events TO metabase;
After the next sync, or Sync database schema now on the database page, s2b_events appears under the connection. A question that counts rows and sums cents by event returns 53 order.paid events and 416100 cents on the sample data.
MySQL works the same way with the MySQL tables. Its generated columns, such as event and received_at, already show up as plain columns.
BigQuery
Create the s2b.records view from BigQuery, then add a BigQuery database in Metabase with a service account JSON key. Give the service account the BigQuery Data Viewer and BigQuery Job User roles on the project, and nothing that can write. Metabase runs every question as a BigQuery job billed to that project, so filter on date in native queries and dashboard filters.
Athena, Trino and Starburst
- Athena: create the table and view from Athena, then add an Amazon Athena database with the region, workgroup, S3 staging directory and an access key whose IAM policy allows Athena queries, reads on the Send2Bucket prefix, and writes only to the query results location.
- Trino or Starburst: Metabase's Starburst driver connects to Trino as well. Fill in host, port, catalog (for example
icebergorhive), and a user with read access to the tables from Trino.
ClickHouse, Redshift and Snowflake
Add the database type of the same name, with a user that can only read the tables you created by following ClickHouse or Redshift. For Snowflake, use a role with USAGE on the database and schema and SELECT on the tables or views. The example queries on each engine page run as native queries unchanged.
DuckDB and MotherDuck
Metabase has no built-in DuckDB driver. MotherDuck maintains a community driver:
- Download
duckdb.metabase-driver.jarfrom the MotherDuck driver's releases into Metabase's plugins directory (MB_PLUGINS_DIRfor Docker), and restart Metabase. Use a Debian or Ubuntu based image, not Alpine. - Add a DuckDB database. For Database file, enter
md:<database>and paste a read-scoped MotherDuck token, or give the path of a DuckDB file on the Metabase host. - Query the views you created by following MotherDuck. The DuckDB example queries run as native queries.
Metabase Cloud cannot load custom drivers. There, add a PostgreSQL connection to MotherDuck's Postgres endpoint instead, as described in MotherDuck's Metabase guide. Queries sent that way are DuckDB SQL.
Notes
- Metabase syncs table and column names hourly and scans column values daily by default. Neither copies your records, and every question queries the database when it runs, unless you set a caching policy under Admin settings > Performance.
- Data in a loaded table is as fresh as the last load. Set dashboard auto-refresh no shorter than your load schedule.
- Records in
dataare JSON events and OTLP records mixed together. Filter onsignalin every question, or use views per signal as above.