The TimeSeries model is designed for time series data, making it ideal for scenarios like IoT device monitoring and machine data collection. It supports high-concurrency writes and queries, and provides low-cost storage for petabytes of data. This topic explains how to use the TimeSeries model in the Tablestore console.
To use the TimeSeries model with the CLI, see Use the TimeSeries model with the CLI.
Usage notes
The TimeSeries model is available in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Ulanqab), China (Shenzhen), China (Chengdu), China (Hong Kong), Japan (Tokyo), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Germany (Frankfurt), UK (London), US (Silicon Valley), US (Virginia), and Saudi Arabia (Riyadh).
Features such as Lastpoint index, analytical storage for time series, custom time series identifiers, and data fields as primary keys are available only in the China (Hangzhou), China (Shanghai), China (Beijing), and China (Zhangjiakou) regions. To use these features, create your TimeSeries model instance in one of the specified regions.
Before you begin
Activate Tablestore. For more information, see Activate Tablestore.
Create a TimeSeries model instance.
Log on to the Tablestore console.
In the top navigation bar, select a resource group and a region.
On the Overview page, click Create Instance for TimeSeries Model.
In the Create Instance for TimeSeries Model dialog box, select an instance type, enter an instance name, and add an instance description based on your business needs.
Click OK.
Procedure
Step 1: Create a time series table
Create a time series table to store your time series data.
For more information about the sample scenario and table schema, see Sample scenario.
Go to the Instance Management page.
Log on to the Tablestore console.
In the top navigation bar, select a resource group and a region.
On the Overview page, click the instance name, or click Manage Instance in the Actions column for the instance.
On the Instance Details tab, click the Time Series Tables tab.
On the Time Series Tables tab, click Create Time Series Table.
NoteYou can also click Generate Demo with One Click to create a test table with sample data to quickly try out the feature. The system initializes the new test table, so you may need to wait a few moments for the time series data to appear.
In the Create Time Series Table dialog box, set Time Series Table Name to car_example and keep the default settings for other parameters.

Click Create.
After the time series table is created, you can view it on the Time Series Tables tab. If the new table does not appear in the list, click the
icon to refresh the list of time series tables.
Step 2: Write data
Write time series data to the time series table. Time series data consists of metadata and data points. If metadata for a time series does not exist, the system automatically creates it when you write the data.
On the Time Series Tables tab, click the name of the time series table and then click the Query Data tab. Alternatively, click Manage Data in the Actions column for the table.
(Optional) Add a new time series.
On the Query Data tab, click Add Time Series.
In the Add Time Series dialog box, add the metadata for the time series, such as the measurement name and data source.

Click Add.
Insert data.
In the Actions column of the target time series, click Query Data.
Click Insert Data.
The system automatically retrieves the metadata of the selected time series.
In the Insert Data dialog box, set the time and property columns.

Click OK.
Step 3: Query time series data
Query data points for a specific time series within a specified time range.
To query data from the table by using an SQL query, see Use SQL to query time series data.
You can search for a specific time series by specifying multiple conditions. For more information, see Search for a time series.
On the Query Data tab of the time series table, find the target time series and click Query Data in the Actions column.
Set the query conditions.
By default, query results are sorted by time in ascending order. To sort data in reverse chronological order, set Reverse Chronological Order to Yes.
Select a query method and specify the time range.
Click Query.
The matching data is displayed on the Query Data tab. You can view the results as a list or a chart.
Use a Lastpoint index
A Lastpoint index allows you to quickly retrieve the latest data point for each time series in a table.
Go to the Instance Management page.
Log on to the Tablestore console.
In the top navigation bar, select a resource group and a region.
On the Overview page, click the instance name, or click Manage Instance in the Actions column for the instance.
Go to the time series table management page.
On the Instance Details tab, click the Time Series Tables tab.
On the Time Series Tables tab, click the name of the time series table.
Create a Lastpoint index.
On the Basic Information tab of the time series table management page, click Create Lastpoint Index.
In the Create Lastpoint Index dialog box, set a name for the Lastpoint index and select a synchronization method.

Click Create.
Use the Lastpoint index to query data.
In the Actions column of the Lastpoint index, click Query.
In the Search dialog box, set Mode to Range Search and keep the default settings for other parameters.
The start primary key defaults to the minimum value and the end primary key defaults to the maximum value for _#h, _m_name, _data_source, and _tags.

Click Query.
The data that meets the query conditions is displayed in the Lastpoint Index section on the Basic Information tab.
Search for a timeline
You can find a specific time series by searching with multiple conditions, such as its measurement name or data source.
On the Query Data tab of the time series table, click Query Time Series in the upper-right corner.
In the Query Data dialog box, enter the measurement name or data source for the time series. You can also click Add to set matching conditions for tags, properties, or update times.
The conditions in the following figure are used to query all time series that have the tag
car_model=model_A.
Click OK.
The time series that meet the conditions are displayed on the Query Data tab.
Sample scenario
In an Internet of Vehicles (IoV) use case, vehicle sensors report time series data to the cloud. By storing, querying, and analyzing this data, you can build applications for vehicle status reports, vehicle positioning, traffic management, and trajectory tracking. This topic uses an IoV scenario to demonstrate how to create a time series table and manage its data. The table, named car_example, stores vehicle data, primarily vehicle trajectory information. The table schema is detailed below.
Parameter | Type | Description |
_m_name | String | The measurement name. It represents the physical quantity or metric that the time series data measures. |
_data_source | String | The data source. It identifies the source of the time series data. This field can be empty. |
_tags | String | The tags for the time series. You can define multiple string key-value pairs. |
_time | Integer | The time when the data is reported. |
vin_id | String | The Vehicle Identification Number (VIN), which uniquely identifies the vehicle. |
model | String | The vehicle model. |
speed | Double | The current speed. |
gps | String | The GPS coordinates of the vehicle in |
current_mileage | Double | The current mileage. |
remaining_oil | Double | The remaining fuel. |
available_mileage | Double | The remaining driving range. |
tire_pressure | Double | The tire pressure data. |
Related documents
For more information about the Lastpoint index, see Lastpoint index.