ClickHouse is a common home for time-series data, from logs and infrastructure metrics to sales and customer activity. Our own internal logging platform, LogHouse, stores more than a quadrillion time series rows. Forecasting future values and detecting unusual observations are common tasks for this data, but training and maintaining a separate classical time series model, like ARIMA, for every service, customer, or product can be difficult as the number of series grows.
Time-series foundation models (TSFMs) promise to remove that per-series training requirement: pretrained on many series, they can produce zero-shot forecasts from a new series' history, which can also be used to flag observations that deviate from expectations. This makes them a natural fit for ClickHouse's real-time analytics and data warehousing workloads, where SQL already handles the aggregation, time bucketing, and filtering needed to construct each series.
In this post, we connect TimesFM 3.0 to ClickHouse through executable user-defined functions. As an illustration, we use recorded retail sales from the M5 dataset to forecast daily demand and identify unusual historical observations.
Setup
The companion clickhouse-timeseries-ai
repository contains a TimesFM…