content/commands/ts.alter.md
Update the retention, chunk size, duplicate policy, and labels of an existing time series
is key name for the time series.
</details><note><b>Note:</b> 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. </note>
is maximum retention period, compared to the maximum existing timestamp, in milliseconds. See RETENTION in [TS.CREATE]({{< relref "commands/ts.create/" >}}).
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]({{< relref "commands/ts.create/" >}}). Changing this value does not affect existing chunks.
is policy for handling multiple samples with identical timestamps. See DUPLICATE_POLICY in [TS.CREATE]({{< relref "commands/ts.create/" >}}).
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]({{< relref "commands/ts.create/" >}}).
Create a temperature time series.
{{< highlight bash >}} 127.0.0.1:6379> TS.CREATE temperature:2:32 RETENTION 60000 DUPLICATE_POLICY MAX LABELS sensor_id 2 area_id 32 OK {{< / highlight >}}
Alter the labels in the time series.
{{< highlight bash >}} 127.0.0.1:6379> TS.ALTER temperature:2:32 LABELS sensor_id 2 area_id 32 sub_area_id 15 OK {{< / highlight >}}
</details>| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |
{{< multitabs id="ts-alter-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
OK when the time series is altered successfully.-tab-sep-
One of the following:
OK when the time series is altered successfully.{{< /multitabs >}}
[TS.CREATE]({{< relref "commands/ts.create/" >}})
[RedisTimeSeries]({{< relref "/develop/data-types/timeseries/" >}})