Retention tiers without rewriting storage
Retention is usually implemented as deletion, which is both expensive and destructive. We downsample instead: data younger than 30 days keeps full resolution, older data collapses into 5-minute buckets with min, max, mean and count preserved.
Queries that need raw resolution are answered only for the full-resolution window, and the API returns an explicit resolution field so clients never silently receive aggregated numbers where they expected raw ones.
Handling clock skew in field devices
Field devices drift. Cheap RTCs lose minutes per month, and devices that lose power frequently come back with wildly wrong time. Trusting device timestamps makes time-series queries lie.
We correct at ingest: each batch carries a device sequence number, and we estimate offset against a monotonic counter. Measurements keep their relative ordering, and the corrected offset is stored alongside the raw value so the original is never lost.