Configuration Parameters

RedisTimeSeries supports multiple module configuration parameters. All of these parameters can only be set at load-time.

Setting configuration parameters on module load

Setting configuration parameters at load-time is done by appending arguments after the --loadmodule argument when starting a server from the command line or after the loadmodule directive in a Redis config file. For example:

In redis.conf:

loadmodule ./ [OPT VAL]...

From the Redis CLI, using the MODULE LOAD command:> MODULE LOAD [OPT VAL]...

From the command line:

$ redis-server --loadmodule ./ [OPT VAL]...

RedisTimeSeries configuration parameters

The following table summarizes which configuration parameters can be set at module load-time and run-time:

Configuration Parameter Load-time Run-time
NUM_THREADS (since RedisTimeSeries v1.6)
ENCODING (since RedisTimeSeries v1.6)
OSS_GLOBAL_PASSWORD (since RedisTimeSeries v1.8.4)
IGNORE_MAX_TIME_DIFF (since RedisTimeSeries v1.12)
IGNORE_MAX_VAL_DIFF (since RedisTimeSeries v1.12)


The maximal number of per-shard threads for cross-key queries when using cluster mode (TS.MRANGE, TS.MREVRANGE, TS.MGET, and TS.QUERYINDEX). The value must be equal to or greater than 1. Note that increasing this value may either increase or decrease the performance!




$ redis-server --loadmodule ./ NUM_THREADS 3


Default compaction rules for newly created key with TS.ADD.

Note that COMPACTION_POLICY has no effect on keys created with TS.CREATE. To understand the motivation for this behavior, consider the following scenario: Suppose a COMPACTION_POLICY is defined, but then one wants to manually create an additional compaction rule (using TS.CREATERULE) which requires first creating an empty destination key (using TS.CREATE). But now there is a problem: due to the COMPACTION_POLICY, automatic compactions would be undesirably created for that destination key.

Each rule is separated by a semicolon (;), the rule consists of multiple fields that are separated by a colon (:):

  • Aggregation type: One of the following:

    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 (since RedisTimeSeries v1.8)
  • Duration of each time bucket - number and the time representation (Example for one minute: 1M, 60s, or 60000m)

    • m - millisecond
    • s - seconds
    • M - minute
    • h - hour
    • d - day
  • Retention time - number and the time representation (Example for one minute: 1M, 60s, or 60000m)

    • m - millisecond
    • s - seconds
    • M - minute
    • h - hour
    • d - day

    0m, 0s, 0M, 0h, or 0d means no expiration.

  • (since RedisTimeSeries v1.8):

    Optional: Time bucket alignment - number and the time representation (Example for one minute: 1M, 60s, or 60000m)

    • m - millisecond
    • s - seconds
    • M - minute
    • h - hour
    • d - day

    Assure that there is a bucket that starts at exactly alignTimestamp after the epoch and align all other buckets accordingly. Default value: 0 (aligned with the epoch). Example: if bucketDuration is 24 hours, setting alignTimestamp to 6h (6 hours after the Epoch) will ensure that each bucket’s timeframe is [06:00 .. 06:00).

When a compaction policy is defined, compaction rules will be created automatically for newly created time series, and their key would be set to:

  • Before RedisTimeSeries v1.8:

    key_dur_agg where key is the key of the source time series, dur is the bucket duration, and agg is the aggregator.

  • Since RedisTimeSeries v1.8:

    key_dur_agg_aln where key is the key of the source time series, dur is the bucket duration, agg is the aggregator, and aln is the alignment timestamp.


  • max:1M:1h - Aggregate using max over one minute and retain the last hour
  • twa:1d:0m:360M - Aggregate daily [06:00 .. 06:00) using twa; no expiration


No compaction rules.


$ redis-server --loadmodule ./ COMPACTION_POLICY max:1m:1h;min:10s:5d:10d;last:5M:10m;avg:2h:10d;avg:3d:100d


Default retention period, in milliseconds, for newly created keys.

Retention period is the maximum age of samples compared to highest reported timestamp, per key. Samples are expired based solely on the difference between their timestamp and the timestamps passed to subsequent TS.ADD, TS.MADD, TS.INCRBY, and TS.DECRBY calls.

The value 0 means no expiration.

When both COMPACTION_POLICY and RETENTION_POLICY are specified, the retention of newly created compactions is according to the retention time specified in COMPACTION_POLICY.




Setting the default retention to 300 days:

$ redis-server --loadmodule ./ RETENTION_POLICY 25920000000


Is policy for handling insertion (TS.ADD and TS.MADD) of multiple samples with identical timestamps, with one of the following values:

policy description
BLOCK ignore any newly reported value and reply with an error
FIRST ignore any newly reported value
LAST override with the newly reported value
MIN only override if the value is lower than the existing value
MAX only override if the value is higher than the existing value
SUM 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.

Precedence order

Since the duplication policy can be provided at different levels, the actual precedence of the used policy will be:

  1. TS.ADD's ON_DUPLICATE_policy optional argument
  2. Key-level policy (as set with TS.CREATE's and TS.ALTER's DUPLICATE_POLICY optional argument)
  3. The DUPLICATE_POLICY module configuration parameter
  4. The default policy


The default policy is BLOCK. Both new and pre-existing keys will conform to this default policy.


$ redis-server --loadmodule ./ DUPLICATE_POLICY LAST


Default chunk encoding for automatically created keys when COMPACTION_POLICY is configured.


Note: Before RedisTimeSeries 1.6 this configuration parameter was named CHUNK_TYPE.




$ redis-server --loadmodule ./ COMPACTION_POLICY max:1m:1h; ENCODING COMPRESSED


Default initial allocation size, in bytes, for the data part of each new chunk, for newly created time series. Actual chunks may consume more memory.




$ redis-server --loadmodule ./ COMPACTION_POLICY max:1m:1h; CHUNK_SIZE_BYTES 2048


Global OSS cluster password used for connecting to other shards.


Not set


$ redis-server --loadmodule ./ OSS_GLOBAL_PASSWORD password


A new sample is considered a duplicate and is ignored if the following conditions are met:

  1. The difference of the current timestamp from the previous timestamp (timestamp - max_timestamp) is less than or equal to IGNORE_MAX_TIME_DIFF;
  2. The absolute value difference of the current value from the value at the previous maximum timestamp (abs(value - value_at_max_timestamp) is less than or equal to IGNORE_MAX_VAL_DIFF;
  3. The sample is added in-order (timestamp ≥ max_timestamp).





$ redis-server --loadmodule ./ IGNORE_MAX_TIME_DIFF 1 IGNORE_MAX_VALUE_DIFF 0.1
Back to top ↑