Improve logs compression with log clustering
Drain3 log template mining, run inside ClickHouse as a Python executable UDF, can turn unstructured application logs into structured columnar data. Templates mined from a sample of each service's logs become regex patterns in a materialized view, which extracts variable fields into a Map column keyed by template number at ingest time. Two templates covered 99.99% of one service's logs, and unmatched lines are kept raw. The approach reached nearly 50x compression while keeping logs queryable and fully reconstructable, though evaluating every pattern against every log line needs optimization to scale.
Related posts
- 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.
- Clever ingests 200x more logs at the same cost with ClickHouse Cloud
ClickHouse mediumAdept
Clever replaced a split Datadog/Athena logging setup with ClickHouse Cloud. It now indexes all ~150 TB/month of logs from 400 services and 200 Lambdas with 60-day retention, a 200x increase in searchable volume, at no extra cost and with 10x compression. The schema extracts hot fields into columns and stores the rest as raw JSON plus an attributes map. It uses token bloom filter indexes at granularity 32 for full-text search, date partitions with a 60-day TTL, and orders by negative Unix timestamp for an 8-10x query speedup. Resilience comes from separate dev and per-region prod services joined via remoteSecure and merge tables, all managed with Terraform and Goose. A custom LogQL-to-SQL layer keeps Grafana familiar for engineers.
- How Canva achieved 10x faster search and 70% lower costs with ClickHouse
ClickHouse mediumAdept
Canva moved tracing and logging (about 3 million spans and 3 million logs per second) onto a self-managed ClickHouse cluster of 5 shards × 3 replicas on Kubernetes. It reached a 14x compression ratio, cut costs by about 70%, and brought P90 trace search down from 30s to 2.5s. The ingestion gains came from batching roughly 200k spans per insert in OpenTelemetry collectors and writing straight to local tables. Search speed came from a sorting key aligned with Jaeger's filters, daily partitions, a materialized-view lookup table keyed by trace ID, and a client-side sliding search window. Logs flow through Kinesis and Lambda using tuned async inserts, with ngram Bloom filters on flattened log strings for free-text search and a custom DSL query gateway.
- Scaling observability at Character.AI: thousands of GPUs, 10x logs, and 50% lower cost with ClickStack
ClickHouse mediumAdept
Character.AI consolidated fragmented logging across multi-cloud Kubernetes GPU clusters onto ClickStack (HyperDX UI) backed by ClickHouse Cloud. It ingests 10x more log data at 50% lower cost, and log searches that took minutes now return in seconds. Raw output of about 450 PB/month is tamed with aggressive sampling: errors and warnings are kept in full, while info logs are sampled at 1 in 10,000 for the backbone service and 1% elsewhere. OpenTelemetry Collector DaemonSets insert directly with async inserts and batching. Schema tuning included primary keys aligned to time and service queries, materialized columns extracted from JSON, pruned skip indexes and per-column compression, yielding roughly 15–20x compression. Collector misconfiguration, such as missing batching or unsampled ingestion, caused outages, and a gateway layer plus native JSON and PromQL support are planned next.
- How trip.com migrated from Elasticsearch and built a 50PB logging solution with ClickHouse
ClickHouse mediumAdept
Trip.com replaced its Elasticsearch-based centralized logging platform with ClickHouse after hitting stability, ingestion and cost limits at 4PB, and has since grown it toward 50PB. The migration used a ReplicatedMergeTree schema with daily partitions, ZSTD codecs, LowCardinality columns, tag key/value arrays and tokenbf_v1 bloom-filter indexes. Kibana was extended with custom ClickHouse panels, and scripts migrated 95% of dashboards automatically. The result was over 50% storage savings and queries 4–30x faster (P90 under 300ms). Further growth caused ZooKeeper-driven DDL timeouts, which led trip.com to split into multiple clusters and to evaluate ClickHouse Cloud with SharedMergeTree.