Building an Observability Solution with ClickHouse - Part 1 - Logs
ClickHouse can serve as the storage backend for Kubernetes log collection using any of three agents: the OpenTelemetry Collector, Vector and Fluent Bit. Each agent can be deployed via Helm in agent (DaemonSet) and aggregator roles. Aggregators batch data into larger inserts that match ClickHouse insert best practices, and small deployments that skip them should use asynchronous inserts to avoid too many parts. The OTEL exporter (alpha) hard-codes its schema, while Vector (beta, HTTP/JSON sink) lets users define their own tables. Map types are recommended for sparse Kubernetes labels and annotations, and the post closes with compression results and example SQL queries for analyzing logs by pod, time window and string or regex match.
Related posts
- ClickHouse and OpenTelemetry
ClickHouse mediumAdept
ClickHouse now officially supports the OpenTelemetry Collector exporter for ClickHouse, which has reached beta for logs and traces. The exporter ships a "one size fits most" default schema. For production, ClickHouse recommends disabling automatic table creation, because concurrent exporters race to create tables, and defining your own tables or materialized views keyed to your query patterns. The LogHouse schema behind ClickHouse's 43 PB internal logging platform serves as the worked example. It orders by (PodName, Timestamp), uses LowCardinality for string columns under about 10k distinct values, applies ZSTD(1) because data lives on S3, and puts Bloom-filter indexes on map keys and values, which are not yet tuned.
- Sending Kubernetes logs To ClickHouse with Fluent Bit
ClickHouse mediumAdept
Fluent Bit deployed as a Kubernetes DaemonSet via its Helm chart can enrich container logs with Kubernetes metadata and ship them to ClickHouse over the HTTP interface using JSONEachRow inserts. A nest filter places all fields under a JSON `log` column, and a Lua filter lifts `host` and `pod_name` to top-level LowCardinality(String) columns so they can serve in the MergeTree primary key alongside timestamp. Recommended practices: use the experimental JSON Object type only for dynamic fields, explicitly type known fields, drop unused fields to avoid column explosion, and tune Fluent Bit's default 1s flush so ClickHouse receives batches of at least ~1000 rows. A sample Grafana dashboard (ID 17284) visualizes the resulting data.
- Building an Observability Solution with ClickHouse - Part 2 - Traces
ClickHouse mediumAdept
Trace data from OpenTelemetry-instrumented services can be stored and queried in ClickHouse, treating spans as rows in a single analytics table and visualizing them in Grafana. The walkthrough uses a ClickHouse fork of the OpenTelemetry Demo, configuring the OTEL Collector's contrib ClickHouse exporter with batching (5s or 100k spans), retries, TTL-based retention and secure endpoints, deployable via Docker Compose or Helm. Practical caveats include the exporter's hard-coded schema (pre-create tables to control types and codecs), its alpha status, and the need to pre-create non-default databases, followed by tips on schema optimization for the otel_traces table.
- 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.
- 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.