Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 17 min read How-to mediumAdept

Instrumenting your NextJS application with OpenTelemetry and ClickStack

ClickPy, a Next.js app over ClickHouse serving 1.8 trillion rows of PyPI download data, is instrumented with OpenTelemetry via ClickStack (ClickHouse, HyperDX and an OTel collector) to capture browser sessions and distributed traces. The HyperDX browser SDK adds session replay, console and network capture, and traceparent propagation that links frontend spans to server spans. The Node.js SDK is wired in through Next.js instrumentation.js with header-capture environment variables. Custom spans around a central query function record each ClickHouse query's timing, rows returned, settings and the dashboard component that issued it, so slow dashboard loads can be traced to specific queries and package properties.

Related posts

  • Introducing ClickStack embedded in ClickHouse

    ClickHouse mediumAdept

    Starting with ClickHouse 26.2, the ClickStack (HyperDX) observability UI ships inside the ClickHouse binary at /clickstack, adding about 4 MB, for local exploration of logs, traces, metrics and ClickHouse's own system tables. It is not meant for production: there is no persistent state, so alerting, saved dashboards and saved queries are unavailable, and Event Patterns is removed because the Pyodide WASM runtime is too large. The Next.js app is exported as static files and pulled in through a git submodule, so the ClickHouse build never needs Node.js. A CMake step gzips the files and generates a sorted C++ array that an HTTP handler binary-searches. A walkthrough shows how to enable system.query_log and point a log source at it.

  • Whats new in ClickStack - June + July

    ClickHouse mediumAdept

    ClickStack's June–July update centers on traces: per-service colors in the waterfall, fixed-pixel minimum span widths, a minimap for navigating long traces, and display of OpenTelemetry span links. Metrics gain an experimental proxy to external Prometheus-compatible endpoints for hybrid migration to the ClickHouse TimeSeries Engine, plus quantile support for exponential histograms via scale normalization, offset alignment and log-linear interpolation matching Prometheus. Filter values and autocomplete now try ClickHouse text indexes via mergeTreeTextIndex() (26.3+) before metadata rollups and table scans. Other additions include cascading dashboard filters, consecutive-window alerts with a PENDING state, categorical bar charts, event-pattern tiles, kiosk mode, and expanded External API v2 CRUD.

  • ClickStack: A (half) year in review

    ClickHouse easyNovice

    ClickStack, the ClickHouse-based observability stack built on HyperDX and OpenTelemetry, shipped a run of features between its May launch and December. These include native JSON attribute storage, a ClickHouse Cloud-hosted UI, dashboard import/export and custom collector configs, and time-window chunked search that fetches recent data first and stops early. Later months added threshold alerting on isolated compute pools, configurable Event Deltas, and Service Maps in beta. December's integrated materialized views let the query layer use EXPLAIN ESTIMATE to pick whichever registered incremental view scans the fewest granules, accelerating searches, charts and dashboards automatically.

  • Using Event Patterns in ClickStack to accelerate observability analysis

    ClickHouse mediumAdept

    ClickStack clusters logs and traces into event patterns at query time using the Drain3 template-mining algorithm, which runs in the browser via Pyodide (Python compiled to WebAssembly). Clustering at ingest was rejected because the overhead is too high at gigabytes-per-second ingestion rates. Instead, each search result set is sampled down to about 10,000 evenly distributed events with a cityHash64-modulo sampling query that avoids ORDER BY rand(), returning clusters within seconds. The recommended workflow is to filter broadly by service or severity, treat rare patterns as leads, then pivot to raw search or traces. Future work could run Drain3 as a ClickHouse UDF and compile the learned templates into ingest-time extraction rules for better compression.

  • What's new in ClickStack. September '25.

    ClickHouse mediumAdept

    ClickStack's September 2025 release adds JSON dashboard import/export in HyperDX, custom aggregations through any ClickHouse aggregate function (e.g. stddevPop), and user-supplied OTel Collector YAML. That YAML is merged with the OpAMP-managed base config by mounting it at /etc/otelcol-contrib/custom.config.yaml, for example to add hostmetrics and filelog receivers. Search queries are now split into time-window chunks executed newest-first, with remaining chunks canceled once enough results are found. A Prometheus-style delta() for gauge metrics extrapolates each window's first-to-last difference to the full bucket duration before aggregating across series.

The quest for software engineering knowledge.

Look:
Layout: