You can use the TimeSeries model to store, query, and analyze time series.

Precautions

  • The TimeSeries model starts charging fees since May 26, 2022.
  • The TimeSeries model is available in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), Germany (Frankfurt), and Singapore (Singapore).

Background information

Tablestore is a multi-model data storage service that is developed by Alibaba Cloud. Tablestore can store large amounts of structured data and supports a variety of data models, including the TimeSeries model.

The TimeSeries model is designed based on the characteristics of time series data. This model is suitable for scenarios such as IoT device monitoring and can be used to store the data collected by devices and the monitoring data of machines. The TimeSeries model provides the following benefits:
  • Provides a unified-common modeling method for time series data, which eliminates the need to predefine table schemas.
  • Allows metadata indexes to be automatically created for time series and supports time series retrieval based on composite conditions.
  • Supports queries and aggregation by using SQL.
  • Supports automatic scale-out of service capabilities, high-concurrency writes and queries, and low-cost storage of petabytes of data.

Terms

Term Description
Time series data Time series data consists of multiple time series. Each time series is a set of data points that are arranged in chronological order. In addition, some metadata is needed to identify a time series. Therefore, time series data consists of metadata and data.
  • Metadata: records the identifiers and properties of all time series.
  • Data: records the data points of all time series. The data points include the time when the data points are generated and the corresponding data values.
Timeline In time series data, a timeline is often used to refer to a time series. In the TimeSeries model of Tablestore, timelines and time series are equivalent.
Timeline metadata Timeline metadata, also known as time series metadata, contains the identifier and properties of a timeline. The identifier is used to uniquely identify a timeline. The properties can be modified and can be used for time series retrieval.
Timeline identifier A timeline identifier is also called a time series identifier and is used to uniquely identify a timeline. In the TimeSeries model of Tablestore, a time series identifier consists of the following three parts: metric name, data source, and tag.
Metric name The name of a physical quantity or metric for data in a time series, such as cpu or net, which indicates that the CPU usage or network usage is recorded in the time series.
Data source The identifier of the data source for the time series. This parameter can be empty.
Tag The tag of the time series. You can customize multiple key-value pairs of the string type.
Property Properties are part of time series metadata and can be used to record some modifiable property information of a time series. However, the properties cannot be used as the identifier of a time series and cannot be used to uniquely identify a time series. The properties of a time series are multiple key-value pairs of the string type, which are similar to tags in the format. You can specify or update the properties of a time series to retrieve the time series by using the properties.
Data in a time series A data point in a time series consists of the time when the data is generated and the corresponding data value. If only one value is generated at each moment in a time series, the single-value model is used. If multiple values are generated at each moment in a time series, the multi-value model is used.

The TimeSeries model of Tablestore uses the multi-value model. You can specify multiple data values at one point in time. Each value corresponds to a column in the time series table, including the column name and column value. Column values support the following data types: Boolean, integer, floating-point, string, and binary.

Data model

In the TimeSeries model of Tablestore, a two-dimensional time series table is used to store time series data.

Each row represents the data at a point in time in a time series. The time series identifier and timestamp are the primary key columns of the row, and the data points of the time series under the timestamp are the data columns of the row. A row can contain multiple data columns. You do not need to predefine the schemas of the primary key columns and data columns. You only need to specify the names of the specific data columns when you write data to the time series table.

A time series table can store time series data of different metric types. In the following figure, the time series table stores data of the following two metric types: temperature and humidity.

fig_timestreamsample

In the figure, the measurement, data source, and tags parameters form a time series identifier. You can use an API operation to update the properties in the metadata of a time series. The properties can be used to retrieve the time series.

After data is written to a time series table, the system automatically extracts the metadata of the time series and automatically creates a metadata index. You can retrieve a time series based on the combination of the metric name, data source, and tags.

Features

  • Create and manage time series tables

    You can use the Tablestore console, SDKs, or CLI to query all time series tables in an instance, create a time series table, query the configurations of a time series table, update the configurations of a time series table, and delete a time series table.

    When you create a time series table or update the configurations of a time series table, you can specify the time to live (TTL) for the data in the time series table. After the TTL value is specified, the system automatically checks the difference between the current time and the timestamp of the time series data. If the difference exceeds the TTL value, the system automatically deletes the expired data.

  • Read and write time series data

    You can use the Tablestore console, SDKs, or CLI to write multiple rows of time series data to a time series table at the same time. After data is written to the time series table, you can specify a time series identifier to query the data in the time series within the specified time range.

  • Retrieve time series

    You can use the Tablestore console, SDKs, or CLI to retrieve time series in a time series table. You can use a composite condition that consists of multiple conditions to retrieve time series. For example, you can retrieve all time series in which the metric name is cpu, the tags contain a tag whose name is region and value is hangzhou, and the properties contain a property whose name is status and value is online. After the time series are retrieved, you can call an API operation to further query the data in the time series.

  • Implement SQL query and analytics

    Time series tables support queries by using SQL. In SQL, you can specify the metadata condition to filter time series and aggregate data based on the aggregation operations in different dimensions. For example, you can query the average value of the sample data from a batch of devices and aggregate second-level data into minute-level data.

    In addition, you can query only the metadata of time series in SQL. This way, you can manage the metadata of time series by using SQL.

Limits

For more information, see Limits on the TimeSeries model.

Usage

You can have a quick try of the TimeSeries model by using the Tablestore console, SDKs, or CLI.