Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Expose ClickHouse to an embedded dashboard through a server-side Analytics API, not directly from the browser. The API authenticates the user, checks whether that user may access the requested tenant, injects a tenant constraint into a parameterized query, and connects to ClickHouse with a read-only identity. It then returns a short-lived, tenant-scoped token for the browser and tags every query so usage can be aggregated by tenant.

This design keeps database credentials and raw schema details out of client code while combining application authorization with ClickHouse RBAC, row policies, column grants, settings profiles and quotas. The same query log can show each tenant’s query count, scanned bytes, memory, duration and cache behavior—useful for operational chargeback, although those measures are not automatically the same as a cloud provider invoice.

What is the secure architecture for an embeddable ClickHouse analytics API?

The browser or an internal dashboard should call your Analytics API. Only that API should connect to ClickHouse. A typical request flows through four trust boundaries:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Identity: The API validates the caller’s session or access token.
  2. Application authorization: A policy service, such as an OpenFGA relationship check, determines whether the caller may view the requested tenant.
  3. Query enforcement: The API selects an allow-listed metric and dimension set, binds tenant and date parameters, and runs the query through a read-only ClickHouse role. A ClickHouse row policy or tenant-scoped view provides a second enforcement point.
  4. Embedding and telemetry: The API issues a short-lived token for the embedded client, tags the database query with tenant and user context, and records usage for later aggregation.

The tenant identifier supplied by a browser is only a request hint. It is never proof that the caller belongs to that tenant. Derive the effective tenant from the authenticated identity and an authorization decision, then compare it with any requested tenant before querying.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Why put the API in the middle?

A direct browser-to-ClickHouse connection would expose a database endpoint, credentials or a powerful client-side token and would reveal more schema than the dashboard needs. An API can hide those details, normalize errors, enforce maximum date ranges, limit expensive dimensions, apply rate limits and change the storage layout without rewriting the client.

How do application authorization and ClickHouse controls work together?

Use defense in depth: authorize in the application and enforce the boundary again inside ClickHouse. The application decides whether a person may view a tenant; ClickHouse ensures that an accidental or malicious query cannot read another tenant’s rows.

Application policy check

After validating the user’s identity, ask your policy layer whether that identity has an allowed relationship to the tenant and analytics scope. OpenFGA is one example of a relationship-based policy engine; the exact model and identity provider depend on your system. Deny by default when the check fails, is unavailable, or returns an ambiguous result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ClickHouse RBAC and row policies

Define users and roles for database and table privileges. Attach a row policy to the reporting role so ClickHouse automatically filters rows for that role. A policy can enforce the tenant predicate even if a future API endpoint forgets to add it.

Column restrictions are expressed through grants. Give the analytics role only the columns that an embed is allowed to query. A SELECT * that would include a restricted column should fail instead of silently returning sensitive data. Prefer a curated view when several dashboards need the same safe shape.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Why the ClickHouse identity must be read-only

Use a principal that can select from approved tables or views and cannot insert, update, delete, alter, drop or copy partitions. ClickHouse documents the reason explicitly: “Row policies makes sense only if you have readonly access. If you can modify table or copy partitions between tables, it defeats the restrictions of row policies.” A write-capable identity could bypass the intended isolation by changing data or moving partitions.

How should tenant and date inputs be bound safely?

Use ClickHouse parameter binding and allow-lists. Never concatenate a tenant ID, date, metric, sort direction or dimension supplied by a client into SQL text.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bind values, do not interpolate them

A query can use typed placeholders such as {tenantId: String} and {startDate: DateTime}:

SELECT event_date, sum(revenue) AS revenue
FROM analytics_events
WHERE tenant_id = {tenantId: String}
  AND event_time >= {startDate: DateTime}
  AND event_time < {endDate: DateTime}
GROUP BY event_date
ORDER BY event_date

The API supplies the values through the ClickHouse client’s parameter mechanism. Validate that the end is after the start, cap the maximum interval, and reject malformed timestamps before the query reaches the database.

Allow-list identifiers

Parameters are for values, not SQL identifiers. Map a client-facing metric such as revenue to a server-side expression, and map dimensions such as country or plan to known columns. Accept sort directions only from a fixed set such as asc and desc. Reject unknown names rather than attempting to sanitize arbitrary SQL.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Limit expensive requests

Set a maximum date range and a bounded page or result size. Consider separate endpoints for summary cards and detailed tables so a dashboard cannot request an unbounded export through the same path. Query-complexity settings can cap an individual query, while quotas handle usage over a time interval.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does the short-lived embed-token flow protect credentials?

An authenticated backend endpoint should mint the browser token. The browser receives permission to call the Analytics API, not a ClickHouse username, password or unrestricted database token.

  1. The user signs in and requests an embed for a tenant.
  2. The backend verifies the session and performs the application authorization check.
  3. The backend creates a token containing a stable user identifier, the authorized tenant, and a narrow scope such as analytics:read.
  4. The token is signed by the backend and given a short expiration. An implementation example uses expiresIn: '1h'; treat one hour as a value to review against session length, revocation requirements and the sensitivity of the data, not as a universal rule.
  5. The embedding code sends that token to the Analytics API on each request. The API validates the signature, expiry, scope and tenant before querying ClickHouse.

Do not put the ClickHouse host, credentials, table names or raw schema in browser JavaScript. Use HTTPS, restrict token audience and issuer, and avoid placing tokens in URLs where they can leak through browser history and proxy logs. If a user loses access before expiry, a token deny-list or a short-lived session exchange can provide faster revocation than waiting for natural expiration.

How can query logs attribute cost and usage to each tenant?

Add tenant and user context to every query, then aggregate ClickHouse’s system.query_log after the query finishes. A SQL comment is a simple tagging technique, provided your client and logging configuration preserve it:

/* tenant_id=acme user_id=u_482 dashboard=retention */
SELECT ...

Keep the tag values bounded and non-sensitive; never place a password, access token or personal data in a query comment. If your logging pipeline parses structured context separately, that can be more robust than relying on comment parsing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Useful QueryFinish fields

  • query_count or a count of finished rows for the number of completed queries.
  • read_bytes for data scanned.
  • memory_usage for peak memory attributed to the query log entry.
  • query_duration_ms for elapsed execution time.
  • Cache-hit information, when your deployment records it, to distinguish work avoided by caching from work performed by ClickHouse.

A reporting query can group finished entries by the tenant tag and a time window:

SELECT
    extractTenant(query) AS tenant_id,
    count() AS queries,
    sum(read_bytes) AS bytes_read,
    sum(memory_usage) AS memory_bytes,
    sum(query_duration_ms) AS duration_ms
FROM system.query_log
WHERE type = 'QueryFinish'
  AND event_time >= {from: DateTime}
  AND event_time < {to: DateTime}
GROUP BY tenant_id

The exact tag-extraction expression depends on how you format comments; many teams instead write the context to a separate event stream and join it to query-log records. Retain enough information to explain a bill, but apply a retention period and access controls because query logs can reveal tenant activity.

Scanned bytes, memory, duration and query count are operational attribution signals. They are not automatically equivalent to a ClickHouse Cloud invoice or to the full cost of self-managed infrastructure. Combine them with storage, compute, support and network accounting when setting a chargeback formula.

Which ClickHouse limits should protect a shared analytics service?

Use both interval quotas and per-query settings. They address different failure modes.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quotas for sustained usage

A quota limits cumulative activity over a time window. A ClickHouse knowledge-base example creates a quota allowing 10 result rows per 10-second interval (ClickHouse, 2023). That figure is illustrative, not a sensible default for every dashboard. Choose limits from observed workload, tenant contracts and acceptable burst behavior, and decide whether quota exhaustion should return an explicit error or route the tenant to a lower-cost report.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Settings for one expensive query

Query-complexity settings apply to an individual query regardless of how much quota remains. Useful controls include maximum execution time, maximum rows or bytes read, maximum result size and memory limits. Pair them with a maximum date range in the API so users receive a predictable validation error before ClickHouse starts a large scan.

Graceful failure

  • Return a clear authorization error when the policy check fails; do not reveal whether another tenant exists.
  • Return an expiry or re-authentication response when the embed token is no longer valid.
  • Explain quota or complexity rejection as a limit, and include a request identifier for support without exposing SQL.
  • If the cost-attribution pipeline is delayed, continue serving queries only if your governance policy permits it; otherwise fail closed for tenants whose usage cannot be accounted for.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What design choices should you compare before deployment?

Evaluate the service against the same axes rather than choosing a control in isolation.

Axis Options and implications
Authorization boundary Application policy engine, ClickHouse row policy, or both. Both reduce the chance that one missed check becomes a data breach.
Credential exposure Raw database credentials expose the database to the client; short-lived scoped tokens expose only the API permission needed for the embed.
Isolation strength A tenant predicate is the basic boundary; a row policy or view adds database enforcement; separate tables or databases provide stronger physical separation at higher operational cost.
Cost signal Scanned bytes, memory, duration, query count and cache-hit rate explain workload. None alone is a complete invoice measure.
Operational model Self-managed ClickHouse offers infrastructure control but requires capacity, upgrades and monitoring. ClickHouse Cloud reduces operational work but changes networking, account controls and available billing data.
Failure behavior Define deny-by-default authorization, token expiry handling, quota rejection responses and whether analytics can degrade when attribution or a policy dependency is unavailable.

Should you use ClickHouse Cloud or run ClickHouse yourself?

The choice is an operating-model decision, not an access-control substitute. ClickHouse describes self-managed cost as dependent on compute, storage and management headcount. Its homepage has advertised ClickHouse Cloud as starting at $50 per month; that is a volatile list price and should be verified for your region, usage and date before budgeting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compare networking requirements, private connectivity, backup and upgrade responsibilities, support expectations, tenant-level billing data and the controls your compliance program requires. In either model, keep the Analytics API and read-only database identity: a hosted service does not make direct browser credentials safe.

What is a practical implementation checklist?

  • Create a dedicated read-only ClickHouse role with grants only to approved views, tables and columns.
  • Add a row policy or equivalent tenant-scoped view and test it with cross-tenant negative cases.
  • Implement an application authorization check before every embed and data request.
  • Derive the tenant from trusted identity and policy data; never trust a browser-supplied tenant ID alone.
  • Bind tenant and time values with typed parameters and allow-list every metric, dimension and sort option.
  • Enforce maximum date ranges, result sizes, execution time and memory settings.
  • Issue signed, short-lived tokens containing only the user, tenant and read scope needed by the embed.
  • Tag queries with bounded tenant and user context, and aggregate finished entries from system.query_log.
  • Document quota thresholds, revocation behavior, policy-service outages and attribution retention.
  • Run penetration tests that attempt SQL injection, cross-tenant access, token replay, restricted-column selection and quota bypass.

Frequently Asked Questions

Can a ClickHouse row policy replace the application authorization check?

No. A row policy protects rows after a database connection is made, but it does not decide whether a person should receive an embed token or call a particular dashboard. Keep the application decision and the database policy separate so a compromised API route or mis-issued token has a second barrier.

What should happen when the authorization service is unavailable?

For sensitive tenant data, fail closed and issue no new embed token or query authorization. A previously issued token may continue only under an explicitly documented risk policy; otherwise require a fresh decision when the policy dependency recovers.

How do I prevent a tenant from inferring another tenant through errors or timing?

Use the same generic not-authorized response for nonexistent and unauthorized tenant IDs, avoid returning row counts before authorization, and keep validation and query limits consistent. Review aggregate dashboards for small-count suppression if they could reveal information about another tenant.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How long should query-log attribution data be retained?

Set retention from accounting, security and privacy requirements rather than choosing an arbitrary duration. Keep enough history to reconcile the chargeback period, restrict access to the logs, and remove or hash user context when detailed identity is no longer needed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.