TS.ALTER

Syntax
TS.ALTER key 
  [RETENTION retentionPeriod] 
  [CHUNK_SIZE size] 
  [DUPLICATE_POLICY policy] 
  [IGNORE ignoreMaxTimediff ignoreMaxValDiff] 
  [LABELS [label value ...]]
Available in:
Redis Stack / TimeSeries 1.0.0
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

Examples

Required arguments

key

is key name for the time series.

Note: This command alters only the specified element. For example, if you specify only RETENTION and LABELS, the chunk size and the duplicate policy are not altered.

Optional arguments

RETENTION retentionPeriod

is maximum retention period, compared to the maximum existing timestamp, in milliseconds. See RETENTION in TS.CREATE.

CHUNK_SIZE size

is 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 policy

is policy for handling multiple samples with identical timestamps. See DUPLICATE_POLICY in TS.CREATE.

IGNORE ignoreMaxTimediff ignoreMaxValDiff

is 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.

Return value

Returns one of these replies:

  • Simple string reply - OK if executed correctly
  • [] on error (invalid arguments, wrong key type, key does not exist, etc.)

Examples

Alter a temperature time series

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
OK

Alter 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

See also

TS.CREATE

RedisTimeSeries


RATE THIS PAGE
Back to top ↑