Available in: Redis Stack
Time complexity: O(N) where N is the number of labels requested to update
Update the retention, chunk size, duplicate policy, and labels of an existing time series.
TS.ALTER key [RETENTION retentionPeriod] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [LABELS [{label value}...]]
key - Key name for time series
RETENTION
retentionPeriod - Maximum retention period, compared to maximal existing timestamp (in milliseconds).
CHUNK_SIZE
size - memory size, in bytes, allocated for each data chunk. Must be a multiple of 8 in the range [128 .. 1048576].
DUPLICATE_POLICY
policy - Policy for handling samples with identical timestamps. One of the following values:
BLOCK
- an error will occur for any out of order sampleFIRST
- ignore any newly reported valueLAST
- override with the newly reported valueMIN
- only override if the value is lower than the existing valueMAX
- only override if the value is higher than the existing valueSUM
- If a previous sample exists, add the new sample to it so that the updated value is equal to (previous + new). If no previous sample exists, set the updated value equal to the new value.When not specified, the server-wide default will be used.
LABELS
[{label value}...] - Set of label-value pairs that represent metadata labels of the key
If LABELS
is specified, the given label-list is applied. Labels that are not present in the given list are removed implicitly.
Specifying LABELS
with no label-value pairs will remove all existing labels.
TS.ALTER temperature:2:32 LABELS sensor_id 2 area_id 32 sub_area_id 15
LABELS
is specified, but RETENTION
isn't, only the labels are altered.