Skip to main content
Last updated on

Metabase

{/* Knowledge type: Procedure /} {/ Applicable scenario: Connect to Apache Doris in Metabase and build visualization dashboards */}

Metabase is an open source business intelligence tool that provides data analysis, data visualization, interactive dashboards, data drill-down, SQL query editing, and data export. With the Metabase Apache Doris Driver, Metabase can integrate Apache Doris databases and tables as data sources to query Doris internal data and external data, and to build visualization dashboards.

The driver is a standalone Metabase community driver and is not built into Metabase.

This article starts from user scenarios and describes how to complete the following operations:

ScenarioUser goalMain operations
Prepare the Metabase environmentAllow Metabase to recognize Apache Doris as a data sourceInstall Metabase, then download and install the Doris driver
Configure the Doris data sourceConnect to the Doris tpch database in MetabaseFill in the FE node, Query Port, Catalog, database, username, and password
Build visualization analyticsAnalyze how order amounts of different shipping methods change over timeCreate a Question, write SQL, configure a line chart, and save it to a dashboard
Use advanced capabilitiesAccess external data sources and improve the query experienceUse Catalog, parameterized queries, partition pruning, materialized views, and caching

Prepare the Metabase environment

Prerequisites

Before you start configuration, make sure the following environment is ready:

ItemRequirement
MetabaseDownload and install Metabase 0.59.6.3 or later. For installation instructions, see the Metabase installation documentation
JavaJava 21 is required to run Metabase
Apache DorisPrepare an accessible Apache Doris cluster
Doris driverDownload the Metabase Doris Driver

Download and verify the driver

Download the Release JAR and its checksum file:

curl -LO https://github.com/xylaaaaa/metabase-doris-driver/releases/download/v1.0.0/doris.metabase-driver-v1.0.0.jar
curl -LO https://github.com/xylaaaaa/metabase-doris-driver/releases/download/v1.0.0/doris.metabase-driver-v1.0.0.jar.sha256
sha256sum -c doris.metabase-driver-v1.0.0.jar.sha256

The expected SHA-256 digest is as follows:

b23e82f19a7f9226343e42566e1e192b6df7a0dfc48a73d2101fc74bfec243f3

Install the driver for a regular deployment

If Metabase is deployed in the regular way, install the Doris driver as follows:

  1. Download and verify the driver Release files as described above.

  2. If the Metabase plugins directory does not exist, create it:

    mkdir -p /path/to/metabase/plugins
  3. Copy the Release JAR to the plugins directory:

    cp doris.metabase-driver-v1.0.0.jar /path/to/metabase/plugins/doris.metabase-driver.jar
  4. Restart the Metabase service.

  5. Check the Metabase startup log to confirm that the doris driver is registered. In Admin Settings > Databases > Add database, you should be able to see the Apache Doris database type.

Install the driver for a Docker deployment

If you start Metabase with Docker, you are recommended to start it by mounting doris.metabase-driver.jar. The plugin path inside the Docker container is /plugins/.

  1. Download and verify the driver Release files.

  2. Start the container with a Metabase image that meets the prerequisites:

    docker run -d \
    -p 3000:3000 \
    --name metabase \
    -v "$(pwd)/doris.metabase-driver-v1.0.0.jar:/plugins/doris.metabase-driver.jar:ro" \
    metabase/metabase

Configure the Doris data source

{/* Knowledge type: Configuration parameters /} {/ Applicable scenario: Add an Apache Doris database connection on the Metabase admin page */}

After installing Metabase and metabase-doris-driver, you can add a data source in Metabase that connects to the Doris tpch database.

Connection parameters

The following fields are required when connecting to Apache Doris:

ParameterMeaningExample
Display NameDisplay name of the data sourceDoris-TPCH
HostDoris FE node address127.0.0.1
PortDoris Query Port (MySQL protocol port), defaults to 90309030
CatalogCatalog name. Optional, defaults to internalinternal
Database (optional)The database in the selected Catalog. Optional; when left empty, all visible databases in the Catalog are discoveredtpch
UsernameUsernameroot
PasswordPasswordyour_password
SSLEnable JDBC TLS. The driver uses MariaDB sslMode=trust and does not verify the server certificate or hostnamefalse
Sync Schemas IncludeOptional. Used when Database (optional) is empty. A comma-separated allowlist of databasestpch
Sync Schemas ExcludeOptional. Used when Database (optional) is empty. A comma-separated denylist of databases. The exclude rule takes precedence over the include ruleinformation_schema
Additional JDBC connection string optionsOther MariaDB JDBC URL parametersconnectTimeout=10000

Select the Catalog and database scope as follows:

  • Internal tables: Keep Catalog as internal and fill in a database such as tpch.
  • External tables: Fill in the external Catalog and a database visible in that Catalog.
  • Multiple databases: Leave Database (optional) empty. The driver discovers the databases visible to the configured account, and applies the include and exclude lists before listing the tables in them.

When Database (optional) is empty, the driver excludes information_schema, __internal_schema, and mysql by default. The include and exclude rules are matched case-insensitively; if the same database appears in both lists, the exclude rule takes precedence. If Database (optional) is set explicitly, the sync scope is limited to that database, and the include and exclude settings do not change the sync scope.

Configuration steps

  1. Start Metabase and complete the login.

  2. Click the gear icon in the upper right corner and select Admin Settings.

Metabase admin settings

  1. In the left menu, select Databases, and click the Add database button in the upper right corner.

Add database

  1. In the Database type dropdown, select Apache Doris.

Select Apache Doris

  1. Fill in the connection information:

    ParameterExample value
    Display nameDoris-TPCH
    Host127.0.0.1
    Port9030
    Cataloginternal
    Database (optional)tpch
    Usernameadmin
    Password******

Fill in connection information

  1. Click Save to save the configuration.

  2. Metabase tests the connection and starts synchronizing database metadata. If the connection succeeds, a success message is displayed.

Connection succeeded

After the data source configuration is complete, you can build visualizations in Metabase.

Build a visualization dashboard

{/* Knowledge type: Procedure /} {/ Applicable scenario: Use Doris TPC-H data to create a Question and a Dashboard in Metabase */}

This example uses TPC-H data as the data source. For how to build the Doris TPC-H data source, see the Doris TPC-H benchmark documentation.

Suppose you need to analyze how the order amounts of different shipping methods grow over time for cost analysis. You can complete the visualization configuration with the following workflow.

Create a Question

  1. Click the New + button in the upper right corner of the home page and select Question.

Create a new question

  1. Select the data source:

    ParameterExample value
    DatabaseDoris TPCH
    Tablelineitem

Select a table

Build a custom metric with SQL

To compute the revenue, you need to use a custom SQL expression.

  1. Click view sql in the upper right corner, then click convert this question to SQL to edit the SQL.

Switch to SQL mode

  1. Enter the following SQL query:

    SELECT
    DATE_FORMAT(l_shipdate, '%Y-%m') AS ship_month,
    l_shipmode,
    SUM(l_extendedprice * (1 - l_discount)) AS revenue
    FROM lineitem
    WHERE l_shipdate >= '1995-01-01'
    AND l_shipdate < '1997-01-01'
    GROUP BY
    DATE_FORMAT(l_shipdate, '%Y-%m'),
    l_shipmode
    ORDER BY ship_month, l_shipmode
  2. Click the Visualize button in the lower right corner to view the results.

View results

Configure the visualization chart

  1. By default, the result is shown as a table. Click the Visualization button in the lower left corner and select the Line chart type.

Select line chart

  1. Configure the chart parameters as needed. Metabase generates the following configuration automatically:

    ConfigurationExample valueMeaning
    X-axisship_monthShipping month
    Y-axisrevenueRevenue
    Seriesl_shipmodeShipping method
  2. Customize the chart style:

    • Click the Settings icon to adjust colors, labels, legend position, and so on.
    • On the Display tab, you can set axis titles, number formats, and so on.
  3. After the chart is configured, click Save in the upper right corner to save it.

  4. Enter the question name my-tpch and select the Collection to save it to.

Name the question

Create a Dashboard

  1. Click + New > Dashboard to create a new dashboard, and enter the dashboard name my-tpch.

Create a dashboard

  1. Click Add a chart to add the saved Question to the dashboard.

Add a question

  1. Adjust the chart position and size, and click Save in the upper right corner to save the dashboard.

Save the dashboard

You have now successfully connected Metabase to Apache Doris and completed data analysis and visualization dashboard creation.

Driver capabilities and limitations

The following table summarizes the driver capabilities and current support boundaries.

CapabilitySupport status and boundaries
Internal CatalogSupports synchronizing and querying Doris internal tables
Native SQLSupported. SQL is executed with the permissions of the configured Doris account; the driver does not force statements to be read-only
Query BuilderSupports group aggregation and bucketing by day
External CatalogSupports synchronizing and querying data in Doris External Catalogs; the available scope and metadata completeness depend on the specific connector
Native template parametersSupports numeric, text, and optional blocks
Complex typesTop-level ARRAY, MAP, JSON, and opaque complex fields remain visible; nested subfields are not expanded
Key and index metadataPrimary keys, foreign keys, indexes, and table permissions are not synchronized
Metabase write featuresData upload, write-back, Actions, data editing, and persisted models are not supported

Advanced scenarios

{/* Knowledge type: Feature description /} {/ Applicable scenario: Access external data sources, create interactive dashboards, and optimize query performance */}

Use Catalog to access external data

Set Catalog and Database (optional) on the connection page to synchronize tables in a Doris external Catalog:

ConfigurationExample valueDescription
Cataloghive_catalogSelect the Doris Catalog named hive_catalog
Database (optional)warehouseSelect the warehouse database in the Catalog

Configure Catalog

Specify the Catalog explicitly in the SQL query:

SELECT * FROM hive.warehouse.orders LIMIT 100;

Use parameterized queries

The driver supports basic Native SQL template parameters. The following example uses a numeric parameter, a text parameter, and an optional block:

SELECT
category,
COUNT(*) AS row_count,
SUM(amount) AS total_amount
FROM orders
WHERE amount > {{min_amount}}
[[AND category = {{category}}]]
GROUP BY category

When category has no value, Metabase removes the entire optional block.

Template capabilitySupport status
Numeric variablesSupported
Text variablesSupported
Optional blocks [[ ... ]]Supported
Field filtersNot supported
Card references such as {{#card-id}}Not supported
Dynamic table referencesNot supported

Data types

During metadata synchronization, the driver maps Doris types to Metabase base types as shown in the following table:

Doris typeMetabase base type
BOOLEANtype/Boolean
TINYINT, SMALLINT, INT, INTEGER, including display widths such as INT(11)type/Integer
BIGINT, LARGEINT, including display widths such as BIGINT(20)type/BigInteger
FLOAT, DOUBLEtype/Float
DECIMALtype/Decimal
DATE, DATEV2type/Date
TIME, including fractional-second precisiontype/Time
DATETIME, DATETIMEV2, TIMESTAMPtype/DateTime
TIMESTAMPTZtype/DateTimeWithTZ
CHAR, VARCHAR, STRING, TEXTtype/Text
JSON, JSONBtype/JSON
ARRAYtype/Array
MAPtype/Dictionary
STRUCT, VARIANT, HLL, BITMAPtype/*

Nested fields inside ARRAY, MAP, JSON, STRUCT, or VARIANT values are not expanded into Metabase subfields. LARGEINT maps to type/BigInteger and does not require conversion to a string.

Performance tuning recommendations

RecommendationDescription
Use partition pruningAdd partition column filter conditions in the WHERE clause, for example WHERE date >= '2024-01-01' AND date < '2024-02-01'
Leverage materialized viewsFor complex aggregation queries, create materialized views in Doris to accelerate the queries
Control result set sizeUse LIMIT to limit the number of returned rows and avoid loading too much data at once
Use query cachingMetabase automatically caches query results. Setting a reasonable cache time can improve performance

Connection and usage tips

ScenarioRecommendation
Driver installationMake sure doris.metabase-driver.jar is placed in the Metabase plugins directory and restart Metabase
Time zone settingsIf you encounter time zone issues, add serverTimezone=Asia/Shanghai to the JDBC connection string
Partitioned table optimizationCreate Doris partitioned tables properly, partitioning and bucketing by time, to effectively reduce the data scanned by queries
Network connectionUse VPC private connections to avoid the security risks of public network access
Permission controlRefine Doris user account roles and access permissions, and follow the principle of least privilege
Metadata synchronizationWhen the table structure in Doris changes, click Sync database schema now on the Metabase admin page to synchronize manually
Performance monitoringFor slow queries, use SHOW QUERY PROFILE in Doris to analyze performance bottlenecks

Abnormal data type display

If the data type display in Metabase is abnormal, first confirm that you are using the latest version of the Doris Driver. For the Doris largeint type, you need to convert it explicitly in SQL:

SELECT CAST(large_int_col AS STRING) FROM table