Available in: Redis Stack
Time complexity: O(1)
Create a compaction rule.
TS.CREATERULE sourceKey destKey AGGREGATION aggregator bucketDuration [alignTimestamp]
sourceKey - Key name for source time series
destKey - Key name for destination (compacted) time series
AGGREGATION
aggregator bucketDuration
Aggregate results into time buckets.
aggregator | description |
---|---|
avg | arithmetic mean of all values |
sum | sum of all values |
min | minimum value |
max | maximum value |
range | difference between the highest and the lowest value |
count | number of values |
first | the value with the lowest timestamp in the bucket |
last | the value with the highest timestamp in the bucket |
std.p | population standard deviation of the values |
std.s | sample standard deviation of the values |
var.p | population variance of the values |
var.s | sample variance of the values |
twa | time-weighted average of all values |
The alignment of time buckets is 0.
destKey should be of a timeseries
type, and should be created before TS.CREATERULE
is called.
Notes:
TS.CREATERULE
with a nonempty destKey can result in an undefined behavior