Skip to content

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

ClickHouse 19 min read Deep dive mediumAdept

ClickHouse vs Prometheus for High Cardinality, Part 2: Cardinality in ClickHouse

ClickHouse handles high-cardinality observability data by storing telemetry as wide events, rows of attributes plus measurements, instead of as independently maintained time series. A new label combination therefore adds a row rather than a new in-memory series object, so cardinality is paid mostly at query time rather than at ingestion. The recommended schema keeps dynamic labels in a sharded Map, materializes frequently filtered labels and metrics into typed columns in the sorting key, and adds inverted text indexes over map keys and values. Sparse primary indexes, granule pruning, per-column codecs and bucketed map serialization (2–49× faster single-key lookups) keep I/O and storage low, though ClickHouse is not a drop-in Prometheus replacement.

Assumes: Prometheus label modelcolumnar storage basicsSQL

Related posts

  • How the D. E. Shaw group powers high-cardinality observability at scale with ClickHouse

    ClickHouse mediumAdept

    The D. E. Shaw group moved per-task resource metrics from its HPC grid, millions of high-cardinality time series keyed by unique task IDs, from an InfluxDB-protocol time-series platform to ClickHouse. In same-hardware benchmarks, a single ClickHouse node ingested about 3.5M samples/s against roughly 480k for a competitor, and queries that timed out elsewhere finished in seconds. Production keeps the InfluxDB line-protocol ingestion path through a custom batching service, backfills history by reading the old platform's files directly from disk, and stores 68 TB compressed on four replicated NVMe servers at about 530k inserts/s, with materialized views for capacity-planning dashboards. Tradeoffs included rewriting Prometheus-style queries in SQL and limited compression on unique-ID fields (up to 5x), while OpenTelemetry traces reach about 12.5x compression.

  • ClickHouse vs Prometheus for High Cardinality, Part 1: Understanding the Problem

    ClickHouse mediumAdept

    High cardinality hurts Prometheus because its storage unit is the individual series. Every unique label combination gets its own in-memory memSeries (~200 bytes plus labels), compressed chunks of about 120 samples, and inverted-index postings. Ephemeral labels such as container_id force constant series creation on the write path, and stale series linger in the Head block for hours until the post-block-cut truncation removes them. The usual mitigations (per-scrape limits, relabeling, longer scrape intervals, dropping labels) protect stability by discarding data, which sets up a follow-on comparison with column-oriented stores like ClickHouse.

  • So, is ClickHouse winning the observability wars?

    ClickHouse mediumAdept

    ClickHouse has become a common storage and query layer for observability, and the main reason is its columnar architecture. Data sorted by an ordering key compresses well (users report 10–50x), queries read only the columns they need, sparse primary and skip indexes prune granules, and execution is vectorized and SIMD-friendly and runs in parallel across shards. The newer inverted-index full-text search cut multi-term log searches in one customer report from 30–45s to about 400ms. High-cardinality fields cost little in a columnar store compared with Prometheus's per-series model, though grouping by millions of values still costs memory. The engine is only the foundation; collection, schema, correlation and workflows still have to be built, which is where ClickStack comes in.

  • Building an Observability Solution with ClickHouse at Dash0

    ClickHouse hardMaster

    Dash0 stores all OpenTelemetry metrics, logs and spans in ClickHouse, using PostgreSQL only for customer settings, so signals can be joined and correlated in one system. The setup tiers storage with 1-2 days on local disk, then AWS S3 plus a local cache, driven by TTL moves, and keeps metrics for 13 months. Tables are ordered by a ResourceHash before Timestamp for better filtering and compression, with daily partitions bounding time ranges, and the cluster runs as a single shard with multiple replicas. Metric metadata is deduplicated into an AggregatingMergeTree table keyed by MetricHash with FirstSeen/LastSeen tracking, and queries against it must use GROUP BY or FINAL because merges are not guaranteed to have happened.

  • Building Chronicle: How Temporal supercharged their observability with ClickHouse

    ClickHouse easyNovice

    Temporal built Chronicle, an observability system on ClickHouse, to handle high-cardinality, per-tenant telemetry for its multi-tenant Temporal Cloud without runaway costs. Data from 14 regions is consolidated into five hubs with distributed tables and AWS PrivateLink, so queries run where the data lives and egress charges stay low. Logs are sorted by cluster, namespace and timestamp for investigative queries, and materialized views pre-aggregate at write time for fast dashboards. Async inserts with a five-second wait push ingestion to 150K rows/s, write-aggregated queries return in under 200 ms, and the largest table compresses 36.59x.

The quest for software engineering knowledge.

Look:
Layout: