Building Data-Driven Warehouse Automation Pipelines with ClickHouse
Step-by-step guide to ingesting high-velocity warehouse telemetry into ClickHouse for sub-second automation decisions and real-time dashboards.
Hook: Why warehouse automation projects fail — and how real-time telemetry fixes them
Warehouse automation teams in 2026 still wrestle with unpredictable robot behavior, intermittent network telemetry, and dashboards that lag the action by minutes. The result: missed SLAs, overworked pickers, and automation systems that can't decide fast enough to prevent a collision or re-sequence a pallet move. If you run warehouse automation, you need a telemetry pipeline that reliably ingests high-velocity events, reduces query latency to sub-second (for decisions), and supports OLAP queries for post-run analysis. ClickHouse is now a go-to OLAP engine for that workload thanks to its speed, tiered storage, and stream integrations. This guide shows a step-by-step architecture and production-grade code to get telemetry from sensors and robots into ClickHouse for real-time automation decisions and dashboards.
Executive summary (what you'll build)
- A resilient, low-latency ingestion pipeline: edge agents → message broker (Kafka/MQTT) → ClickHouse (Kafka engine + Materialized Views)
- Schema design for high-cardinality time-series using MergeTree and AggregatingMergeTree
- Streaming roll-ups and TTL-based retention to control cost
- Operational practices: monitoring, backpressure handling, and CI/CD for schema changes
- Code examples in Python and a simple actuator integration that turns analytics into automation decisions
Why ClickHouse in 2026 for warehouse telemetry?
ClickHouse has evolved rapidly. After large investments in 2025 and 2026, it now offers cloud-managed clusters, better integration with Kafka and object stores, and improved time-series functions — making it a serious choice for telemetry at warehouse scale. Key reasons to pick ClickHouse:
- Sub-second OLAP queries for recent windows (critical for decisions)
- Native streaming ingestion via Kafka engine and HTTP inserts
- Efficient compression and tiered storage to control cost for large retention windows
- Built-in system tables for observability and capacity planning
High-level architecture
Below is a practical architecture used by modern warehouses in 2026 to move telemetry into an analytics/decision layer.
Architecture components
- Edge agents: lightweight Rust/Go agents on robots/sensors that batch and compress telemetry, add device metadata, and retry on failure.
- Gateway: MQTT/Kafka gateway for protocol translation and local buffering—supports QoS for intermittent connectivity.
- Message broker: Apache Kafka (or cloud Kafka) for high-throughput ordered streams; MQTT for lightweight devices with a bridge to Kafka.
- Stream ingestion: ClickHouse Kafka engine + Materialized Views or a stream processor (Materialize/Flink) for complex enrichments.
- OLAP store: ClickHouse MergeTree tables for raw events, AggregatingMergeTree for roll-ups, and tiered storage (S3) for older partitions.
- Decision & actuation: short-circuit rules engine (serverless or microservice) that queries ClickHouse for the last N seconds and triggers actuators.
- Dashboarding & analytics: Grafana using native ClickHouse datasource, and nightly ETL into data warehouse if needed for BI.
Step 1 — Schema design: the foundation for performance
Designing the schema up front matters. Aim for fast inserts, efficient primary key for range queries, and partitioning that avoids too many small parts.
Raw events table (MergeTree)
Create a compact raw table optimized for fast insert and partition pruning by day. Use ORDER BY (device_id, event_time) to make recent per-device queries fast.
CREATE TABLE warehouse.raw_telemetry
(
device_id String,
event_time DateTime64(3),
event_type String,
payload String, -- JSON or compressed binary
battery_level Float32,
x Float32,
y Float32,
z Float32,
tenant_id String
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(event_time)
ORDER BY (device_id, event_time)
SETTINGS index_granularity = 8192;
Aggregated recent-state (AggregatingMergeTree)
Keep a compact, pre-aggregated table for the last-minute view used by automation rules. This reduces query latency for decision services.
CREATE TABLE warehouse.device_minute_aggr
(
device_id String,
minute DateTime64(0),
avg_battery AggregateFunction(avgState, Float32),
count_events AggregateFunction(sum, UInt64),
max_speed AggregateFunction(maxState, Float32)
)
ENGINE = AggregatingMergeTree()
PARTITION BY toYYYYMM(minute)
ORDER BY (device_id, minute);
Step 2 — Ingesting high-velocity telemetry
Two common patterns work well: direct HTTP batch inserts and Kafka-based streaming. Kafka is the recommended production approach because it buffers and handles spikes.
Kafka engine + Materialized View flow
Use a Kafka engine table as a bridge and a Materialized View to insert into MergeTree. This pattern is resilient and easily supports schema evolution.
CREATE TABLE warehouse.kafka_telemetry_raw (
key String,
value String,
partition UInt32,
offset UInt64
)
ENGINE = Kafka
SETTINGS kafka_broker_list = 'kafka:9092',
kafka_topic_list = 'warehouse-telemetry',
kafka_group_name = 'clickhouse-consumer-1',
kafka_format = 'JSONEachRow',
kafka_num_consumers = 4;
CREATE MATERIALIZED VIEW warehouse.kafka_to_merge
TO warehouse.raw_telemetry
AS
SELECT
JSONExtractString(value, 'device_id') AS device_id,
parseDateTime64BestEffort(JSONExtractString(value, 'event_time')) AS event_time,
JSONExtractString(value, 'event_type') AS event_type,
JSONExtractString(value, 'payload') AS payload,
JSONExtractFloat(value, 'battery_level') AS battery_level,
JSONExtractFloat(value, 'x') AS x,
JSONExtractFloat(value, 'y') AS y,
JSONExtractFloat(value, 'z') AS z,
JSONExtractString(value, 'tenant_id') AS tenant_id
FROM warehouse.kafka_telemetry_raw;
Python producer example (batching + gzip)
Edge agents should batch and compress messages. This example shows a Python producer using confluent_kafka to send batched JSON payloads.
from confluent_kafka import Producer
import json, gzip, time
p = Producer({'bootstrap.servers': 'kafka:9092'})
def send_batch(device_id, events):
# events: list of dicts
payload = '\n'.join(json.dumps(e) for e in events)
p.produce('warehouse-telemetry', payload)
p.flush()
# usage
batch = []
for i in range(100):
batch.append({
'device_id': 'robot-42',
'event_time': time.strftime('%Y-%m-%dT%H:%M:%S.%fZ'),
'event_type': 'pose',
'x': 12.3, 'y': 7.8, 'z': 0.0,
'battery_level': 88.2,
'tenant_id': 'fastfulfill'
})
send_batch('robot-42', batch)
Step 3 — Real-time rollups and materialized views for decisions
Materialize minute/second aggregates inside ClickHouse so decision services can query tiny, hot tables instead of scanning raw events.
CREATE MATERIALIZED VIEW warehouse.minute_rollup
TO warehouse.device_minute_aggr
AS
SELECT
device_id,
toStartOfMinute(event_time) AS minute,
avgState(battery_level) AS avg_battery,
sumState(1) AS count_events,
maxState(sqrt((x*x)+(y*y))) AS max_speed
FROM warehouse.raw_telemetry
GROUP BY device_id, minute;
Then use FINAL aggregation when querying or use select finalizeAggregation(avg_battery) from ... to get actual numbers.
Step 4 — Decision engine: sub-second checks and actuation
Most automation decisions use sliding-window queries for the last N seconds. Keep aggregates for per-second or per-10-second windows. Here's a simple decision example in Python that queries ClickHouse HTTP endpoint and triggers a REST actuator when battery < 15% over last 30s.
import requests
CLICKHOUSE_URL = 'http://clickhouse:8123'
def low_battery_action(device_id):
# Query last 30 seconds
q = f"""
SELECT
device_id,
finalizeAggregation(avg_battery) AS avg_battery,
finalizeAggregation(count_events) AS cnt
FROM warehouse.device_minute_aggr
WHERE device_id = '{device_id}'
AND minute >= now() - INTERVAL 30 SECOND
GROUP BY device_id
"""
r = requests.post(CLICKHOUSE_URL, data=q)
print(r.text)
# Parse and decide
# If avg_battery < 15 -> call actuator
# Example actuator call
requests.post('http://actuator:8080/command', json={'device_id': device_id, 'cmd': 'dock'})
For sub-second requirements, keep a small hot table (in-memory) or use ephemeral caches that are fed by ClickHouse's Kafka engine and materialized views. Decision services can subscribe to Kafka topics for anomalies instead of polling.
Step 5 — Retention, cold storage, and cost control
Telemetry accumulates fast. Use these techniques:
- TTL on MergeTree tables to drop raw events after the OLAP retention window (e.g., 30 days).
- Downsample older data into hourly aggregates and move to object storage (S3) using ClickHouse's
ALTER TABLE ... FREEZEor built-in tiered storage. - Use AggregatingMergeTree for compact roll-ups.
ALTER TABLE warehouse.raw_telemetry
MODIFY TTL event_time + INTERVAL 30 DAY TO VOLUME 'hot';
-- Create an hourly downsample table for long-term storage
CREATE TABLE warehouse.hourly_telemetry
ENGINE = SummingMergeTree()
PARTITION BY toYYYYMM(event_time)
ORDER BY (device_id, toStartOfHour(event_time))
AS SELECT device_id, toStartOfHour(event_time) AS hour,
count() AS events_count,
avg(battery_level) AS avg_battery
FROM warehouse.raw_telemetry
GROUP BY device_id, hour;
Step 6 — Observability and operational best practices
Telemetry pipelines must be observable. In 2026, expect to use Prometheus + Grafana + ClickHouse exporters and clickhouse system tables.
- Monitor system.metrics, system.events, system.parts, and system.mutations.
- Export ClickHouse metrics to Prometheus for alerting: ingestion lag, parts count, and query latency.
- Track Kafka consumer lag and key-skew to avoid hotspots (partition by device hashing).
- Use schema migration tooling (clickhouse-migrate or Liquibase plugin) and CI pipelines to deploy DDL safely.
Handling edge cases and reliability
Field reliability matters:
- Backpressure: Ensure Kafka retention and partitioning absorb spikes; scale consumers horizontally.
- Schema evolution: Use JSON or Avro with a schema registry. ClickHouse's JSONEachRow format tolerates missing fields.
- Clock skews: Use event_time from devices but also include server_received_time for ingestion ordering.
- Retries and de-duplication: Include event UUIDs and consider CollapsingMergeTree for deduplication.
Real-world pattern: FastFulfill case study (anonymized)
FastFulfill, a 2026 regional 3PL, migrated its robot telemetry to ClickHouse to reduce decision latency. Problems before migration:
- Dashboards updated every 2-3 minutes
- Actuation rules missed under-rode battery events
- High cloud bill due to scanning raw logs in S3
After implementing the pipeline above (Kafka → ClickHouse Kafka engine → MergeTree + AggregatingMergeTree roll-ups), FastFulfill achieved:
- Median decision latency reduced to ~400ms
- Dashboard refresh to near real-time (5s)
- Storage cost reduction of 60% via TTL and hourly downsampling
This mirrors industry trends in 2026 where warehouses combine workforce optimization with automation to unlock productivity while keeping costs predictable.
Advanced strategies and 2026 trends
What’s trending now and what to plan for:
- Edge-to-cloud hybrid analytics: Lightweight stream processing at the gateway reduces bandwidth by pre-aggregating stateful metrics before sending to the cloud.
- AI-based predictive maintenance: Use ClickHouse as the feature store for models that run near the edge or in a low-latency inference tier.
- Unified observability: Correlate ClickHouse telemetry with APM traces and robotic control logs for root-cause analysis.
- Vendor-neutral pipelines: Design with Kafka + open formats to minimize lock-in; ClickHouse supports standard formats and cloud object stores for portability.
ClickHouse's rapid growth in 2025–2026, backed by major funding rounds, has accelerated features that matter for operational analytics — native streaming, tiered storage, and cloud-managed offerings.
Security, compliance, and multi-tenant considerations
Warehouse telemetry often contains sensitive operational metadata. Best practices:
- Encrypt in transit (TLS) and at rest (SSE-KMS for S3 tiers)
- Use tenant_id and RBAC — isolate reads/writes per tenant via views and user grants
- Audit schema changes and use immutable event logs if required by compliance
CI/CD for ClickHouse schema and pipeline
Treat DDL as code:
- Store DDL in Git and perform review for each change.
- Run a test-runner that applies DDL to a staging ClickHouse cluster and validates queries.
- Use canary partitions (date ranges) to gradually roll out retention and aggregation changes.
Checklist before production launch
- Load-test ingestion to expected 95th-percentile throughput + safety margin
- Validate consumer lag and set autoscaling triggers
- Confirm roll-up latency (materialized views commit time) is within your decision window
- Instrument Prometheus metrics and create SLO-based alerts
- Run disaster recovery drills for cluster failover and object-store recovery
Final notes — trade-offs and when not to use ClickHouse
ClickHouse excels at analytic queries on large volumes and near-real-time rollups. But it’s not a replacement for low-level time-series databases that handle very high cardinality with per-millisecond retention or for transactional state stores. For sub-10ms control loops, keep a local control tier (Redis/SQLite on gateway) and use ClickHouse for decision support and monitoring.
Actionable takeaways
- Start with Kafka as the ingestion backbone to decouple producers and consumers.
- Design MergeTree tables with ORDER BY (device_id, event_time) and partition by month to balance pruning and part size.
- Use Materialized Views to maintain minute/second roll-ups for decision services.
- Apply TTLs and hourly downsampling to control cost; use S3 tiering for older data.
- Instrument everything: system.* tables + Prometheus to detect backpressure early.
Call to action
Ready to build a production-grade telemetry pipeline for warehouse automation? Clone our reference repo (includes Terraform, Kafka topics, ClickHouse DDL, and Python producers) or schedule a 30-minute review of your architecture with our engineers. ClickHouse adoption is accelerating in 2026 — get ahead of the curve and turn telemetry into reliable automation decisions.
Related Reading
- Top Budget Smartwatches of 2026: Long Battery Life Picks Like the Amazfit Active Max
- A Caregiver’s Guide to Cutting Nutrition App Overload and Staying Focused
- 3D Scanning for Authentication: Useful Tool or Placebo for Collectibles?
- Mobile & Remote Psychiatry Resilience (2026): Power, Privacy and Edge‑First Workflows for Clinics on the Move
- E-Bikes for Commuters on a Budget: What to Look for When Buying Cheap Overseas Models
Related Topics
functions
Contributor
Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.
Up Next
More stories handpicked for you
Debugging Silent iPhone Alarms: A Developer’s Perspective
Designing a HIPAA-First Cloud Migration for US Medical Records: Patterns for Developers
Galaxy S26: Maximizing Performance and Cost in Android Development
Alternatives to Starlink: Evaluating Blue Origin's Satellite Solutions
Designing for Color: UI Strategies Inspired by Google's Search Update
From Our Network
Trending stories across our publication group