TS.ALTER key [RETENTION retentionPeriod] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [IGNORE ignoreMaxTimediff ignoreMaxValDiff] [LABELS [label value ...]]
@timeseries,
@write,
@slow,
Update the retention, chunk size, duplicate policy, and labels of an existing time series
keyis key name for the time series.
RETENTION and LABELS, the chunk size and the duplicate policy are not altered.
RETENTION retentionPeriodis maximum retention period, compared to the maximum existing timestamp, in milliseconds. See RETENTION in TS.CREATE.
CHUNK_SIZE sizeis the initial allocation size, in bytes, for the data part of each new chunk. Actual chunks may consume more memory. See CHUNK_SIZE in TS.CREATE. Changing this value does not affect existing chunks.
DUPLICATE_POLICY policyis policy for handling multiple samples with identical timestamps. See DUPLICATE_POLICY in TS.CREATE.
IGNORE ignoreMaxTimediff ignoreMaxValDiffis the policy for handling duplicate samples. See IGNORE in TS.CREATE.
LABELS [{label value}...]is set of label-value pairs that represent metadata labels of the key and serve as a secondary index.
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 removes all existing labels. See LABELS in TS.CREATE.
Create a temperature time series.
127.0.0.1:6379> TS.CREATE temperature:2:32 RETENTION 60000 DUPLICATE_POLICY MAX LABELS sensor_id 2 area_id 32
OKAlter the labels in the time series.
127.0.0.1:6379> TS.ALTER temperature:2:32 LABELS sensor_id 2 area_id 32 sub_area_id 15
OK| Redis Enterprise |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Supported |
✅ Flexible & Annual ✅ Free & Fixed |
One of the following:
OK when the time series is altered successfully.