TS.DOWNSAMPLE
TS.DOWNSAMPLE source destination aggregation bucket
- Group
- Time series
- Complexity
- O(1)
- Arity
- 5 (exactly, counting the command name)
- Flags
- write, slow
- Keys
- first 1, last 2, step 1
- HotKV Cloud
- Performance and Scale
- On-Premise
- requires the time-series license feature
TS.DOWNSAMPLE adds a rule to the time series source: from now on, every
sample added to source with TS.ADD is also added, as
is, to the time series destination. Both series must already exist.
Samples that were in source before the rule are not copied.
The rule is recorded with the aggregation and bucket you give. The
destination holds the raw samples, not aggregated values. To read the
downsampled view, run TS.AGG on the destination with
the same aggregation and bucket. A typical use is to
give the destination a longer retention than the source, or to collect
several sources in one series. The destination’s own retention is applied
when a sample is added to it directly, or by
TS.RETENTION.
aggregation is one of the names TS.AGG accepts, and
bucket a width in milliseconds of at least 1. In cluster mode, both series
must hash to the same slot.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Rule added | Simple string OK |
Simple string OK |
Error replies:
ERR source or destination series not foundERR unknown aggregation typeandERR invalid bucket sizeNOLICENSE ...without thetime-serieslicense feature.
Examples
Section titled “Examples”127.0.0.1:6379> TS.CREATE cpu RETENTION 3600000OK127.0.0.1:6379> TS.CREATE cpu:historyOK127.0.0.1:6379> TS.DOWNSAMPLE cpu cpu:history avg 60000OK127.0.0.1:6379> TS.ADD cpu * 10(integer) 1759400000000127.0.0.1:6379> TS.ADD cpu * 20(integer) 1759400030000127.0.0.1:6379> TS.AGG cpu:history - + 60000 avg1) 1) (integer) 1759399980000 2) "15.000000"The timestamps come from the server clock and will differ.
Compatibility
Section titled “Compatibility”HotKV-only command. It is not the same as RedisTimeSeries TS.CREATERULE:
the destination receives raw samples, and you aggregate when you read.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.