TairTS is a time series data structure that is developed on top of Redis modules. This data structure provides low-latency and high-concurrency in-memory read and write access, supports fast filtering and aggregate queries, and has both storage and computing power. TairTS simplifies the processing of time series data and significantly improves performance.
Overview
- Multi-timeline aggregate queries by using pkeys developed by Alibaba Cloud. Pkeys
have an extra hash layer.
For example, you can create multiple skeys that are named after metric names and device IDs in the foo pkey. Examples: temperature:1, pressure:1, and distance:1. Then, you can run the EXTS.S.MRANGE command provided by TairTS to retrieve custom monitoring data such as skeys that have a device ID of 1. If you want to implement a similar feature by using RedisTimeSeries, you must insert a large number of aggregate queries into business logic code.
Figure 1. Comparison between TairTS and RedisTimeSeries The following section describes the structure of TairTS data:
- Pkey: A pkey is a piece of TairTS data that indicates a set of timelines. A pkey consists of multiple skeys.
- Skey: a timeline. An skey consists of multiple chunks that have a fixed capacity. You can attach one or more different labels to each skey. Then, skeys can be filtered by label.
- Chunk: a data chunk. A chunk can store multiple data points.
- A chunk can have a custom capacity of up to 256 data points.
- Chunks are the smallest expiration units. A chunk is deleted after all data points in the chunk are expired.
- DataPoint: A data point is a piece of time series data that includes a timestamp and a DOUBLE-typed value.
- Aggregate queries in scenarios such as downsampling, attribute filtering, batch query, and the use of multiple numerical functions. This feature integrates batch query and aggregation in a single command to reduce network interaction and provide responses within milliseconds.
- Update and accumulation of historical time series data.
- Configuration of time to live (TTL) for skeys. Each skey can be specified with a TTL and can automatically roll based on time windows.
- Efficient Gorilla compression algorithm and specific storage to drastically reduce costs.
- Storage and computing of monitoring data
- Per-second monitoring for application performance management (APM)
- Data analysis and processing for IoT
- Risk control in throttling scenarios
- Cache of hot news
- Use of time window functions
Best practices
Implement fine-grained monitoring by using TairTSPrerequisites
Precautions
- The TairTS data that you want to manage is stored on the performance-enhanced instance.
- TairTS supports real-time, high-concurrency writes and queries but provides limited storage capacity. As such, we recommend that you specify TTL for TairTS data to ensure that expired data is deleted in a timely manner.
- To reduce storage costs, we recommend that you specify the
CHUNK_SIZE
parameter in the following ways:- If an skey contains more than 5,000 data points on average, set
CHUNK_SIZE
to 256. This is the default value. - If an skey contains less than 5,000 data points on average, set
CHUNK_SIZE
to a value that is calculated by using the following formula: Chunk size = Average number of data points of an skey/20. If an skey contains 1,000 data points on average, setCHUNK_SIZE
to 50.
- If an skey contains more than 5,000 data points on average, set
Supported commands
Type | Command | Syntax | Description |
---|---|---|---|
Basic write operation | EXTS.P.CREATE | EXTS.P.CREATE Pkey |
Creates a TairTS pkey. If a pkey with the same name already exists, the pkey cannot be created. |
EXTS.S.CREATE | EXTS.S.CREATE Pkey Skey [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 label2 val2 ...] |
Creates an skey in a specified pkey. If the pkey does not exist, it is automatically
created. If an skey with the same name already exists, the skey cannot be created.
Note You can specify parameters for the skey, such as the expiration time and whether to
enable compression.
|
|
EXTS.S.ALTER | EXTS.S.ALTER Pkey Skey [DATA_ET time] |
Modifies the metadata of a specified skey. Currently, only the DATA_ET time value can be modified. |
|
EXTS.S.ADD | EXTS.S.ADD Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Inserts a data point into an skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
EXTS.S.MADD | EXTS.S.MADD Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Inserts a data point into multiple skeys of a pkey. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
EXTS.S.INCRBY | EXTS.S.INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Inserts a data point into an skey. If the data point that you want to insert has a positive value, the inserted value is added to the value of the last data point that exists in the skey. If the data point has a negative value, the inserted value is subtracted from the value of the last data point that exists in the skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The default initial value is 0. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
EXTS.S.MINCRBY | EXTS.S.MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Inserts a data point into multiple skeys of a pkey. If the data point that you want to insert has a positive value, the inserted value is added to the value of the last data point that exists in the skey. If the data point has a negative value, the inserted value is subtracted from the value of the last data point that exists in the skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The default initial value is 0. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
EXTS.S.DEL | EXTS.S.DEL Pkey Skey |
Deletes an skey from a pkey and all data points in the skey. |
|
Basic read operation | EXTS.S.GET | EXTS.S.GET Pkey Skey |
Queries the value of the last data point in a specified skey. |
EXTS.S.INFO | EXTS.S.INFO Pkey Skey |
Queries the metadata of a specified skey. The metadata includes the number of data points, the timestamp and value of the last data point, and the label information of the skey. |
|
EXTS.S.QUERYINDEX | EXTS.S.QUERYINDEX Pkey filter1 [filter2 ...] |
Queries the skeys that meet specified filter conditions. |
|
Aggregate operation | EXTS.S.RANGE | EXTS.S.RANGE Pkey Skey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] |
Queries the number of data points that exist in an skey during a specified time range. The time range is a closed interval. |
EXTS.S.MRANGE | EXTS.S.MRANGE Pkey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] [WITHLABELS] FILTER filter1 [filter2 ...] |
Queries the number of data points that meet specified filter conditions in multiple skeys during a specified time range. The time range is a closed interval. |
|
EXTS.P.RANGE | EXTS.P.RANGE Pkey fromTs toTs pkeyAggregationType pkeyTimeBucket [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] [WITHLABELS] FILTER filter1 [filter2 ...] |
Aggregates data points in a pkey that meet specified filter conditions. If you specify one or more skeys for aggregation, the skeys are first aggregated in the same manner as when the EXTS.S.MRANGE command is used. Then, pkeys are aggregated based on the skey aggregation results. |
|
Concurrent write operation | EXTS.S.RAW_MODIFY | EXTS.S.RAW_MODIFY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Modifies the value of a data point in a specified skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
EXTS.S.RAW_MMODIFY | EXTS.S.RAW_MMODIFY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Modifies the values of multiple data points in a specified skey at a time. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
EXTS.S.RAW_INCRBY | EXTS.S.RAW_INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Modifies the value of a data point in a specified skey. You can specify an increment or a decrement by which to modify the value. If the pkey or skey does not exist, the pkey or skey is automatically created. The default initial value is 0. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
EXTS.S.RAW_MINCRBY | EXTS.S.RAW_MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Modifies the values of multiple data points in a specified skey at a time. You can specify an increment or a decrement by which to modify the values. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
|
General-purpose operation | DEL | DEL key [key ...] |
Deletes one or more TairTS keys. |
Uppercase keyword
: the command keyword.Italic
: Words in italic indicate variable information that you supply.[options]
: optional parameters. Parameters that are not included in brackets are required.AB
: specifies that these parameters are mutually exclusive. Select one of two or more parameters....
: specifies to repeat the preceding content.
EXTS.P.CREATE
Item | Description |
---|---|
Syntax | EXTS.P.CREATE Pkey |
Time complexity | O(1) |
Command description |
Creates a TairTS pkey. If a pkey with the same name already exists, the pkey cannot be created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.CREATE
Item | Description |
---|---|
Syntax | EXTS.S.CREATE Pkey Skey [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 label2 val2 ...] |
Time complexity | O(1) |
Command description |
Creates an skey in a specified pkey. If the pkey does not exist, it is automatically
created. If an skey with the same name already exists, the skey cannot be created.
Note You can specify parameters for the skey, such as the expiration time and whether to
enable compression.
|
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.ALTER
Item | Description |
---|---|
Syntax | EXTS.S.ALTER Pkey Skey [DATA_ET time] |
Time complexity | O(1) |
Command description |
Modifies the metadata of a specified skey. Currently, only the DATA_ET time value can be modified. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.ADD
Item | Description |
---|---|
Syntax | EXTS.S.ADD Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(1) |
Command description |
Inserts a data point into an skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.MADD
Item | Description |
---|---|
Syntax | EXTS.S.MADD Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(n), where n indicates the number of data points. |
Command description |
Inserts a data point into multiple skeys of a pkey. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.INCRBY
Item | Description |
---|---|
Syntax | EXTS.S.INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(1) |
Command description |
Inserts a data point into an skey. If the data point that you want to insert has a positive value, the inserted value is added to the value of the last data point that exists in the skey. If the data point has a negative value, the inserted value is subtracted from the value of the last data point that exists in the skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The default initial value is 0. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
The Sample command:
Sample output:
If the
EXTS.S.GET foo temperature command is run at this time, the following output is returned:
|
EXTS.S.MINCRBY
Item | Description |
---|---|
Syntax | EXTS.S.MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(n), where n indicates the number of data points. |
Command description |
Inserts a data point into multiple skeys of a pkey. If the data point that you want to insert has a positive value, the inserted value is added to the value of the last data point that exists in the skey. If the data point has a negative value, the inserted value is subtracted from the value of the last data point that exists in the skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The default initial value is 0. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.DEL
Item | Description |
---|---|
Syntax | EXTS.S.DEL Pkey Skey |
Time complexity | O(1) |
Command description |
Deletes an skey from a pkey and all data points in the skey. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.GET
Item | Description |
---|---|
Syntax | EXTS.S.GET Pkey Skey |
Time complexity | O(1) |
Command description |
Queries the value of the last data point in a specified skey. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.INFO
Item | Description |
---|---|
Syntax | EXTS.S.INFO Pkey Skey |
Time complexity | O(1) |
Command description |
Queries the metadata of a specified skey. The metadata includes the number of data points, the timestamp and value of the last data point, and the label information of the skey. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.QUERYINDEX
Item | Description |
---|---|
Syntax | EXTS.S.QUERYINDEX Pkey filter1 [filter2 ...] |
Time complexity | O(n), where n indicates the maximum number of sets involved in filter conditions. |
Command description |
Queries the skeys that meet specified filter conditions. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.RANGE
Item | Description |
---|---|
Syntax | EXTS.S.RANGE Pkey Skey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] |
Time complexity | O(n), where n indicates the number of chunks to which the data points belong. |
Command description |
Queries the number of data points that exist in an skey during a specified time range. The time range is a closed interval. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.MRANGE
Item | Description |
---|---|
Syntax | EXTS.S.MRANGE Pkey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] [WITHLABELS] FILTER filter1 [filter2 ...] |
Time complexity | O(n), where n indicates the number of chunks to which the data points belong. |
Command description |
Queries the number of data points that meet specified filter conditions in multiple skeys during a specified time range. The time range is a closed interval. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.P.RANGE
Item | Description |
---|---|
Syntax | EXTS.P.RANGE Pkey fromTs toTs pkeyAggregationType pkeyTimeBucket [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] [WITHLABELS] FILTER filter1 [filter2 ...] |
Time complexity | O(n), where n indicates the number of chunks to which the data points belong. |
Command description |
Aggregates data points in a pkey that meet specified filter conditions. If you specify one or more skeys for aggregation, the skeys are first aggregated in the same manner as when the EXTS.S.MRANGE command is used. Then, pkeys are aggregated based on the skey aggregation results. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.RAW_MODIFY
Item | Description |
---|---|
Syntax | EXTS.S.RAW_MODIFY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(1) |
Command description |
Modifies the value of a data point in a specified skey. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.RAW_MMODIFY
Item | Description |
---|---|
Syntax | EXTS.S.RAW_MMODIFY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(n), where n indicates the number of data points. |
Command description |
Modifies the values of multiple data points in a specified skey at a time. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
EXTS.S.RAW_INCRBY
Item | Description |
---|---|
Syntax | EXTS.S.RAW_INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(1) |
Command description |
Modifies the value of a data point in a specified skey. You can specify an increment or a decrement by which to modify the value. If the pkey or skey does not exist, the pkey or skey is automatically created. The default initial value is 0. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
The Sample command:
Sample output:
If the
EXTS.S.GET foo temperature command is run at this time, the following output is returned:
|
EXTS.S.RAW_MINCRBY
Item | Description |
---|---|
Syntax | EXTS.S.RAW_MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
Time complexity | O(n), where n indicates the number of data points. |
Command description |
Modifies the values of multiple data points in a specified skey at a time. You can specify an increment or a decrement by which to modify the values. If the pkey or skey does not exist, the pkey or skey is automatically created. The parameters for the skey, such as the expiration time and whether to enable compression, take effect only if the skey is automatically created. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
Index filtering syntax
Filter command | Description | Logic |
---|---|---|
L = V |
The label L equals V. | EQ (equals) |
L != |
The label L is not NULL, which indicates that the skey includes the label L. | CONTAINS |
L = (v1,v2,...) |
The label L is v1, v2, or another value. | LIST_TMATCH |
L != V |
The label L does not equal V. | NOEQ (equals) |
L = |
The label L is NULL, which indicates that the skey does not include the label L. | NOCONTAINS |
L != (v1,v2,...) |
The label L is not v1, v2, or another value. | LIST_NOTMATCH |
Aggregation syntax
In aggregation operations, data that exists in multiple time buckets is aggregated. The following aggregation types are supported:
MAX
: returns the maximum value.MIN
: returns the minimum value.AVG
: returns the average value.SUM
: returns the sum of all values.FIRST
: returns the first value.LAST
: returns the last value.RANGE
: returns the range from the minimum value to the maximum value.COUNT
: returns the number of values.STD.P
: returns the population variance.STD.S
: returns the sample variance.VAR.P
: returns the population standard deviation.VAR.S
: returns the sample standard deviation.