TUTORIAL17 min read

ClickHouse Embedded Analytics: Build Dashboards Without Seat Fees

A hands-on guide to serving customer dashboards from ClickHouse and Superset, with tenant isolation and no per-viewer BI licence fee.

P
PADISO teamPublished 25 Oct 2026

ClickHouse embedded analytics can give your customers fast, in-product dashboards without a BI licence fee for every viewer. In this tutorial, you will connect ClickHouse to Apache Superset, embed a dashboard in a web app and restrict each customer to its own data. The software has no per-seat licence charge, but you still need to budget for hosting, operations and support. If you are weighing the wider architecture, see PADISO's embedded analytics service.

The goal is not to prove that ClickHouse is always cheaper or faster than a commercial BI product. It is to build a working path from an authenticated application user to a dashboard query, then test that the query is constrained to the right tenant. Your actual cost and response time depend on workload, hosting, data volume, concurrency and the engineering effort you need to operate the stack.

What you will build

The application backend will verify a signed-in customer's permissions, then request a short-lived guest token from Superset. The token grants access to a specific dashboard and carries a row-level security filter for that customer's tenant. The browser mounts the dashboard using Superset's embedded SDK. Superset queries ClickHouse through its database connector.

The basic request path is:

  1. A user signs in to your product.
  2. Your backend gets the tenant identifier from the verified session or its own database, not from an untrusted browser parameter.
  3. Your backend requests a guest token from Superset, including the permitted dashboard and tenant filter.
  4. The browser uses the token to display the embedded dashboard.
  5. Superset applies its security rules when it runs dashboard queries against ClickHouse.

Superset documents this model in its embedded dashboard documentation. Treat the guest token as a short-lived credential, not as a substitute for authenticating your users. For a broader view of design choices, our platform engineering team can help assess data, application and operating requirements together.

What you need before you start

Have these components ready:

  • A ClickHouse server or service reachable from Superset. For a first build, use a development or staging environment rather than production data.
  • Apache Superset, including its metadata database, application secret and a supported deployment process.
  • A web application with a backend that already authenticates users and knows which tenant they belong to.
  • A domain plan for the application and Superset. Hosting them under the same root domain can simplify browser cookie and iframe behaviour.
  • A dataset with a tenant identifier, timestamp and a few measures you can aggregate. Use synthetic or non-sensitive data for initial tests.
  • A way to inspect Superset logs, ClickHouse queries and application server logs.

You should also decide who owns the pieces after the tutorial. The team operating Superset needs to handle upgrades, secrets, backups, access controls and capacity. The application team owns user authentication and the logic that determines tenant access. The data team owns event definitions, retention and query correctness. If those responsibilities are unclear, resolve them before exposing a dashboard to customers.

Keep the cost comparison honest

Superset and ClickHouse are open-source software, so this architecture does not add a per-viewer software licence charge. That does not mean the complete service costs nothing. You pay for compute, storage, networking, backups, monitoring and the people who run it. ClickHouse Cloud lists its own usage-based pricing and billing model in its cloud billing overview; check the current terms for your region and service configuration.

Commercial BI products can price embedded access through platform agreements, capacity or user entitlements. Independent analyses of Tableau embedded analytics pricing and comparisons of Looker versus Tableau pricing models show how quickly per-seat commitments scale. Those terms vary by product, plan and contract. Do not use a generic per-seat estimate as a substitute for a quote. Compare the same workload and include implementation, support, infrastructure and the time needed to operate each option. The practical difference is that this open-source design does not impose a Superset or ClickHouse licence fee for each customer viewer.

Cost area ClickHouse with Superset What to include in your estimate
Software licence per viewer No per-viewer licence charge for the open-source components Verify the licence and terms for the versions and services you choose
Data platform Self-hosted or managed ClickHouse Compute, storage, backups, network and data retention
Dashboard platform Self-hosted Superset Application hosting, metadata database, upgrades, monitoring and support
Engineering and operations Your team or a delivery partner Initial build, security review, incident response and ongoing maintenance
Commercial BI alternative Depends on vendor agreement Platform fee, embedded capacity, viewer access and contract commitments

Use this table to frame a total-cost comparison, not to assume that self-hosting will always win. PADISO's embedded analytics offering starts by examining the audience, data access rules and service requirements alongside the licence model.

Step 1: Create a tenant-aware ClickHouse table

A useful starting point is an event table with a tenant identifier, event time and the measures used in the dashboard. ClickHouse's MergeTree family stores data in sorted parts. Its sparse primary index can help skip data ranges when query filters align with the table's sorting key. It does not create a conventional index entry for every row, and it does not guarantee that a query reads only one tenant's data.

Here is an illustrative table definition:

CREATE DATABASE IF NOT EXISTS customer_analytics;

CREATE TABLE customer_analytics.tenant_events (
    tenant_id LowCardinality(String),
    event_id UUID,
    event_type LowCardinality(String),
    user_id String,
    duration_ms UInt32,
    amount Decimal(18, 4),
    created_at DateTime CODEC(DoubleDelta, ZSTD(1))
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(created_at)
ORDER BY (tenant_id, created_at, event_type);

The example uses monthly partitions and places tenant_id first in the sorting key. That can suit queries that filter by tenant and time. But sorting keys are workload decisions, not a universal recipe. A table with a small number of large tenants, a very high number of small tenants or dashboard queries that mostly group by event type may need a different key. Partitioning is mainly a data management tool. Avoid creating a partition for every tenant, which can create too many small parts.

LowCardinality(String) can be useful for repeated values such as tenant or event type. Check its behaviour against your data and query patterns rather than assuming every string column should use it. The compression codecs shown are examples too. Test them with representative inserts and queries.

Add a small test dataset and confirm its shape

Insert a few rows for at least two tenants. For example, use tenant_red and tenant_blue, different event types and timestamps across more than one day. Then check the row counts:

SELECT tenant_id, count() AS events
FROM customer_analytics.tenant_events
GROUP BY tenant_id
ORDER BY tenant_id;

You should see separate totals for both tenants. If your event pipeline writes late-arriving data, test that behaviour as well. Your product may need to refresh dashboards after ingestion, handle corrections or show that data is current only through a stated timestamp.

Check the query plan before building charts

Run a query that resembles a real dashboard panel:

SELECT
    toDate(created_at) AS day,
    event_type,
    count() AS event_count,
    sum(amount) AS total_amount
FROM customer_analytics.tenant_events
WHERE tenant_id = 'tenant_red'
  AND created_at >= now() - INTERVAL 30 DAY
GROUP BY day, event_type
ORDER BY day;

Inspect the plan and query log using the tools available in your ClickHouse version. Confirm that the query filters on the tenant and time columns, returns the expected rows and reads a sensible volume of data. A tenant-first sort key can help pruning, but sparse indexing works in granules and performance depends on how data is distributed and written. Do not describe a schema as tenant-isolated just because the sort key begins with tenant_id. Isolation is enforced by access controls and query filters, not by sort order.

Step 2: Connect Superset to ClickHouse

Superset needs a database driver in the environment where its web application and workers run. The supplied research points to clickhouse-connect and community guides for connecting ClickHouse to Apache Superset. Install a version tested against your Superset and Python environment, and pin it in your deployment requirements rather than installing it interactively in a running container.

For example, in a container build or managed Python environment:

pip install "clickhouse-connect>=1.8.0,<2.0"

The version range above comes from the supplied setup notes. Confirm compatibility with your deployed Superset version and the Superset ClickHouse driver guide before you pin it. Rebuild and redeploy the Superset web and worker images so every process that needs the connector has it.

In Superset, add a database connection and use the SQLAlchemy connection format supported by the driver, for example:

clickhousedb://analytics_user:REPLACE_WITH_SECRET@clickhouse.internal.net:8443/customer_analytics?secure=true

Use a dedicated database account with only the permissions required by the dashboards. Keep credentials in a secret store or deployment environment, not in source control. Enable TLS when connecting across a network, and validate the certificate settings for your service. The host and port above are examples. Use the values supplied by your deployment.

What you should see

After saving the connection, use Superset's connection test. A successful test means Superset can authenticate and reach ClickHouse. It does not prove that charts work, that the account has the right permissions or that tenant filtering is secure.

Next, create a dataset based on customer_analytics.tenant_events. In SQL Lab, run the sample aggregation query. You should see one row per day and event type for the selected tenant. If connection testing fails, check the Superset web and worker logs, the ClickHouse host and TLS configuration, driver installation and database grants. If the connection works in SQL Lab but a chart fails, inspect the chart query and the permissions available to the Superset role.

Step 3: Enable Superset embedding carefully

Superset's exact configuration options can vary by release. Follow the embedding documentation for the version you deploy, and keep development and production configuration separate. The example below shows the shape of common settings from the supplied notes. Treat it as a starting point, not a drop-in production configuration.

FEATURE_FLAGS = {
    "EMBEDDED_SUPERSET": True,
    "DISABLE_EMBEDDED_SUPERSET_LOGOUT": True,
}

GUEST_ROLE_NAME = "Gamma"
GUEST_TOKEN_JWT_SECRET = "LOAD_A_LONG_RANDOM_SECRET_FROM_SECRET_STORE"
GUEST_TOKEN_JWT_ALGO = "HS256"
GUEST_TOKEN_JWT_EXP_SECONDS = 300

Generate a unique, strong signing secret and keep it out of source control. The guest token expiry shown is five minutes. A short lifetime limits how long a leaked token remains useful, but your frontend must be able to request a replacement when needed. Choose the expiry and renewal behaviour based on your deployment and risk review.

Create a guest role with the least access needed to view the embedded dashboard and its charts. Do not give guest users broad access to SQL Lab, dataset editing or other dashboards unless your product requires it. Verify role permissions in a non-production environment with a guest token before releasing the feature.

Configure the browser boundary

An embedded dashboard runs inside an iframe, so browser rules matter. Configure Superset and your application's content security policy to allow the intended origins and frame relationship. Do not solve a framing problem by broadly disabling browser protections. The example configuration in the brief uses permissive CORS settings and X-Frame-Options: ALLOWALL; do not copy those settings unchanged into production. Allow only the origins your deployment requires, and use the current Superset guidance for iframe and security-header configuration.

A same-root-domain arrangement, such as an application and analytics subdomain under your company domain, may reduce cross-site cookie complications. Test in the browsers your customers use. Cookie policies and iframe behaviour change, so a setup that works in one browser or local environment is not sufficient evidence for production.

Step 4: Mint a guest token on your backend

The backend is the trust boundary. It must authenticate the application user, determine their permitted tenant and dashboard, and then ask Superset to mint a guest token. Never let the browser choose an arbitrary tenant and pass that value directly into an RLS clause.

The following Node.js outline illustrates the sequence. It leaves out application-specific authentication middleware, error handling and token refresh for Superset's service account, all of which you must add before production use.

import axios from 'axios';

async function getGuestToken(tenantId: string, dashboardUuid: string) {
  const login = await axios.post(
    `${process.env.SUPERSET_URL}/api/v1/security/login`,
    {
      username: process.env.SUPERSET_SERVICE_USER,
      password: process.env.SUPERSET_SERVICE_PASSWORD,
      provider: 'db',
      refresh: true,
    }
  );

  const accessToken = login.data.access_token;
  const guest = await axios.post(
    `${process.env.SUPERSET_URL}/api/v1/security/guest_token/`,
    {
      user: {
        username: 'embedded_customer',
        first_name: 'Embedded',
        last_name: 'Customer',
      },
      resources: [{ type: 'dashboard', id: dashboardUuid }],
      rls: [{ clause: `tenant_id = '${tenantId}'` }],
    },
    { headers: { Authorization: `Bearer ${accessToken}` } }
  );

  return guest.data.token;
}

Do not use that string interpolation with an unchecked tenant ID. Derive the ID from the verified application session, then validate it against your own tenant record. Prefer a restricted identifier format, and correctly escape or otherwise safely construct the value for the SQL clause. A tenant identifier containing a quote can change the meaning of a clause if you concatenate it unsafely. Add tests for unusual input, even if your IDs are normally UUIDs.

The service account credentials stay on the backend. Store them securely, rotate them and avoid requesting a fresh Superset login for every dashboard refresh if your deployment's authentication flow supports safe reuse of a service access token. Handle failed logins, Superset timeouts and expired credentials. Return a clear application error without returning internal Superset credentials or stack traces to the browser.

Test the RLS rule before embedding

Superset's embedding documentation describes guest-token resources and row-level security. For a tenant test, mint one token for tenant_red and another for tenant_blue. Load the same dashboard using each token. Confirm that each view shows only its own test records.

Then try to tamper with the tenant in the browser request. The backend should ignore any tenant value supplied by the client and derive access from the authenticated user. Test a user with no tenant, a user whose account is disabled and a user who lacks access to the dashboard. Each should be denied rather than receiving a broad token.

RLS is one layer of the security design. Also restrict database access, protect the Superset service account, avoid sensitive data in chart labels, and review whether exports, downloads and dashboard filters can expose information across tenants. If your application supports a customer user belonging to more than one tenant, model that explicitly and test each permitted context.

Step 5: Embed the dashboard in your application

Create and publish a Superset dashboard, then enable embedding for that dashboard as described in the version-specific docs. Use its embedded dashboard identifier in your application configuration. The browser needs a function that fetches a guest token from your own backend, not directly from a Superset admin endpoint.

A React example using the official SDK looks like this:

import { useEffect, useRef } from 'react';
import { embedDashboard } from '@superset-ui/embedded-sdk';

export function AnalyticsView({ dashboardId }: { dashboardId: string }) {
  const mountPoint = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (!mountPoint.current) return;

    embedDashboard({
      id: dashboardId,
      supersetDomain: 'https://analytics.example.com',
      mountPoint: mountPoint.current,
      fetchGuestToken: async () => {
        const response = await fetch('/api/analytics/guest-token', {
          credentials: 'include',
        });
        if (!response.ok) throw new Error('Could not load analytics');
        const result = await response.json();
        return result.token;
      },
      dashboardUiConfig: {
        hideTitle: true,
        hideChartControls: true,
        filters: { expanded: false },
      },
    });
  }, [dashboardId]);

  return <div ref={mountPoint} style={{ width: '100%', height: 800 }} />;
}

The SDK is maintained in the Superset embedded SDK documentation. Confirm the installed package's current API and match it to your Superset release. The code is an implementation sketch. Add loading, error and teardown behaviour appropriate to your application, and ensure your application endpoint checks the current user on every token request.

What you should see

When a permitted customer opens the page, the dashboard should load inside the product layout. Chart data should reflect the tenant attached to the signed-in user. When the token expires, the SDK should be able to call your backend again and receive a new token, provided the user remains authorised.

If the dashboard area stays blank, inspect the browser console and network panel. Check the iframe response, browser framing errors, the guest-token response, Superset logs and the ClickHouse query log. A failed iframe load often points to a domain or security-header mismatch. A dashboard that loads without data may point to a bad database connection, missing permissions, an invalid dataset or a query error.

Step 6: Build a dashboard that is useful in a product

Start with the customer's task, not the chart catalogue. For example, a customer may need to see weekly usage, compare activity to the prior period and identify the most-used feature. Each panel should answer a clear question and define the metric consistently.

Build a small dashboard first:

  • A headline measure, such as events in the selected period.
  • A time series showing the measure over time.
  • A breakdown by event type or product area.
  • A table of the latest relevant activity, if the product needs detail.
  • A visible date range or data freshness indicator.

Before adding a filter, decide whether it is presentation state or a security boundary. A date filter is usually a user-controlled view preference. The tenant filter is a security rule and must not depend on a customer being unable to change a dashboard control. Keep tenant access in the server-issued token and verify it in tests.

Check the dashboard at the actual iframe dimensions used by your product. Give charts meaningful titles, define units and handle empty results. If customers see dollars, state the currency. If timestamps use a timezone, make that visible. A fast chart that customers interpret incorrectly is not a successful analytics feature. For guidance on structuring executive views that users actually rely on, see our analysis of why executives do not trust dashboards.

Step 7: Check security, correctness and performance

A working demo is not a production test. Use a release checklist that covers the complete request path.

Check How to test it What good looks like
Tenant access Load the dashboard with tokens for two test tenants Each token returns only the matching tenant's records
Client tampering Send a different tenant ID from the browser Backend derives the tenant from the authenticated user and rejects unauthorised access
Dashboard scope Request an unapproved dashboard ID Backend does not mint a token for an unapproved resource
Token exposure Inspect browser requests and application logs No service-account password or signing secret appears in the browser or logs
Query correctness Compare chart totals with a direct ClickHouse query Measures and time ranges match the agreed metric definition
Performance Run representative queries at expected data volume and concurrency Latency and resource use meet your product's stated service target
Failure behaviour Stop Superset or make ClickHouse unavailable in staging Product shows a useful error and recovers cleanly when service returns
Browser compatibility Test supported browsers and mobile layouts Iframe loads, renews credentials and remains usable

Set your own service target before performance testing. Do not assume sub-100ms responses or a fixed number of concurrent queries from a database choice alone. Query shape, data size, hardware, cache state, concurrency and network latency all matter. Test the dashboard queries your customers will actually run, including the largest tenant and busiest expected period.

Use ClickHouse query logs and Superset logs to find repeated expensive queries. For deep-dive operational patterns on preventing worker memory exhaustion under load, refer to our guide on Apache Superset memory pressure and performance. Consider Superset caching for repeated dashboard results where freshness requirements permit it. A cache must not serve one tenant's result to another tenant. Include tenant identity and relevant filters in cache behaviour, and test it explicitly before enabling it for customer-facing use.

Connection pools also need deliberate limits. Superset processes, background workers and ClickHouse each have their own connection and resource limits. A burst of customer page loads can create more concurrent work than an internal analyst dashboard. Load test the whole system, then tune worker counts, query limits, connection limits and caching from observed behaviour. Avoid setting limits by guesswork and leaving them unmonitored.

For teams comparing analytical databases, ClickHouse provides engineering research on real-time analytics alongside PostgreSQL. Use benchmark claims as prompts for your own test, not as a substitute for testing your workload. A PostgreSQL replica may be sufficient for a modest reporting workload, while a column-oriented analytical store may suit broader scans and aggregations. The data shape and workload decide.

Common implementation mistakes

Trusting a tenant value from the browser

A query parameter or front-end state is not proof of a user's tenant. Resolve tenant permissions on the server from the authenticated identity. Mint the token only after checking that the user can access the requested dashboard and tenant.

Treating the sorting key as a security feature

A tenant-first sorting key can help ClickHouse skip irrelevant data ranges. It does not prevent a query from returning another tenant's rows. Enforce tenant restrictions in the query security layer and verify them with adversarial tests.

Giving the guest role too much access

A working dashboard can tempt teams to grant broad Superset permissions. Keep guest permissions narrow and review them after upgrades. Give the guest access only to the intended dashboard and the data required to render it.

Making the iframe work by removing protections

Overly broad CORS rules and frame headers may make a local test pass while widening the production attack surface. Set explicit allowed origins and follow the current Superset and browser security guidance. Test the real production hostnames.

Ignoring operations because the software is open source

You still need backups, upgrades, alerting, capacity planning, incident response and an owner for security patches. A managed service can reduce some operational work, but review its service boundaries, access model and pricing. Self-hosting shifts responsibility to your team rather than eliminating it.

Building too much before validating the metric

A wide dashboard with many charts is harder to review and can issue more queries than needed. Begin with a few customer tasks, validate the numbers against source data and add panels only when they improve a decision or workflow.

A practical rollout sequence

Use a staged rollout rather than turning on embedded analytics for every customer at once.

  1. Prove the data path. Load representative records for two tenants, connect Superset and validate direct queries.
  2. Prove access control. Mint guest tokens for both tenants and test cross-tenant attempts, invalid users and dashboard restrictions.
  3. Prove the user experience. Embed the dashboard in a staging product, test browser behaviour, empty states and token renewal.
  4. Prove operations. Measure query latency and resource use at representative volume. Test logs, alerts, backups and service recovery.
  5. Release to a limited audience. Monitor errors, query cost, load and customer feedback. Expand only when the support and operational process is ready.

Record the decisions as you go: the metric definitions, data freshness, token lifetime, allowed origins, role permissions, query limits and service owner. These details are easy to lose when the first version is built quickly, but they become important when customers depend on the dashboard.

Where PADISO fits

We help product teams shape embedded analytics across the data model, dashboard experience, tenant security and operating architecture. The first step is to review the customer use case, existing data and access model, then define a small workload to test before committing to a production design.

Next step

Write down one customer decision your dashboard should support, one metric that informs it and the tenant rule that protects the data. Then use PADISO's embedded analytics service to assess the design or contact our team to discuss a production implementation.

WANT TO TALK THROUGH YOUR SITUATION?

Talk it through with us. Thirty minutes, no slides.

P
Written by the PADISO TeamSydney-based technology leaders who build what they advise on. Seven years of fractional CTO, architecture and AI work for enterprise, government and private equity.

Keep reading

All posts →

Let's talk.

Tell us what you are weighing up, whether it is a build, a roadmap or a deal. You will leave the call knowing your next step.

Book a 30-min callhi@padiso.co