Back to results for “RedisTimeSeries”
Redis › RedisTimeSeries

How do you configure automatic downsampling in RedisTimeSeries, where detailed recent data is aggregated into coarser summaries over time?

Intermediate

Answer

You create a compaction rule using TS.CREATERULE, specifying a source time series, a destination time series, an aggregation type like average or maximum, and a bucket duration, which automatically creates aggregated data points in the destination series as new raw data arrives in the source, letting you keep detailed recent data while automatically summarizing older data into less granular form.
TS.CREATE temperature_hourly_avg
TS.CREATERULE temperature_sensor1 temperature_hourly_avg AGGREGATION avg 3600000
Real-world example A sensor monitoring system keeps detailed second by second readings for the past day, while automatically maintaining an hourly average time series for long term historical trend analysis, without needing to manually calculate and store these aggregates.

Common follow-ups: What aggregation types are available besides average, such as sum or maximum?;Does downsampling automatically delete the original detailed data?