Storage Layer

Tetrapus persists all telemetry into ClickHouse using a wide telemetry_v2 table. Domain-specific columns are encoded via the DomainCodec trait and decoded at query time. H3 geospatial indexing enables efficient region-scoped queries.

telemetry_v2 Schema

SQL
CREATE TABLE telemetry_v2 (
  ts          DateTime64(3, 'UTC'),
  domain      LowCardinality(String),
  entity_id   String,
  geohash     String,
  h3_r7       UInt64,
  payload     String,        -- JSON domain blob
  dedup_key   UInt64,
  ingested_at DateTime64(3, 'UTC')
) ENGINE = MergeTree()
PARTITION BY (domain, toDate(ts))
ORDER BY    (domain, geohash, ts, entity_id);

Partitioning & Ordering

  • Partition key: (domain, toDate(ts)) — one part per domain per day
  • Order key: (domain, geohash, ts, entity_id) — geo-first for spatial scans
  • TTL: configurable per domain via DomainRegistry

Auxiliary Tables

  • entity_latest_mv — Materialized view: last-known state per entity
  • anomaly_detections — Anomaly scores with Z-score and context
  • audit_log — All control-bus commands and auth events

DomainCodec & Registry

Each domain implements DomainCodec to serialize/deserialize the JSON payload column. The DomainRegistry ships with builtins: hvac, aviation, equity, power-grid, and rail.

H3 Resolution Guide

Resolution Avg Edge (km) Use Case
422.6Country-level rollup
71.22City district (default)
90.174Building-level precision
120.006Sensor-level precision

Use H3QueryController to perform ring and k-ring queries at any resolution. The controller automatically selects the optimal resolution based on viewport zoom.

Questions?

Reach out for help with integration, deployment, or custom domain codecs.