The timeseries model is designed based on the characteristics of time series data. It is suitable for scenarios such as IoT device monitoring, device data collection, and machine monitoring data. It provides high concurrency for writing and querying, along with low-cost storage for PB-level massive data.This topic describes how to use the timeseries model in the console.
For more information on utilizing the timeseries model via the command line tool, see Using the timeseries model with the command line tool.
Notes
Currently, the regions that support the timeseries model feature include China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Ulanqab), China (Shenzhen), China (Chengdu), Hong Kong (China), Japan (Tokyo), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Germany (Frankfurt), UK (London), US (Silicon Valley), US (Virginia), SAU (Riyadh - Partner Region).
Preparations
-
The Tablestore service is activated. For specific operations, see Activate the Tablestore service.
-
Create a timeseries model instance.
-
Log on to the Tablestore console.
-
In the top navigation bar, select the resource group and region.
-
On the Overview page, click Create Timeseries Model Instance.
-
In the Create Timeseries Model Instance dialog box, select the instance type, enter the instance name, and fill in the instance comment based on your business needs.
-
Click OK.
-
Procedure
Step 1: Create a timeseries table
Create a timeseries table to store time series data.
For sample scenarios and table structure information, see Sample Scenarios.
-
Go to the Instance Management page.
-
Log on to the Tablestore console.
-
In the top navigation bar, select the resource group and region.
-
On the Overview page, click the instance name or click Instance Management in the Actions column of the instance.
-
-
On the Instance Details tab, click the Timeseries Table List tab.
-
On the Timeseries Table List tab, click Create Timeseries Table.
NoteYou can also click Generate Sample With One Click to create a test table and sample data for a quick experience of the feature. When a new test table is created, the system performs specific initialization operations. You must wait for dozens of seconds before the time series are displayed.
-
In the Create Timeseries Table dialog box, enter Timeseries Table Name as car_example, and keep other parameters as default.
-
Click OK.
After the timeseries table is created, you can view the created timeseries table on the Timeseries Table List tab. If the newly created table is not displayed in the list, click the
icon to refresh the timeseries table list.
Step 2: write data
Write time series data to the timeseries table. Time series data consists of metadata and data. If you do not create metadata before you write the time series data, the system automatically extracts the metadata from the written data.
-
On the Timeseries Table List tab, click the timeseries table name and then select the Data Management tab or click Data Management in the Actions column of the timeseries table.
-
(Optional) Create a new time series.
-
On the Data Management tab, click Add Time Series.
-
In the Add Time Series dialog box, add time series metadata such as measurement name and data source.
-
Click Add.
-
-
Insert data.
-
Click Query Data in the Actions column of the specified time series.
-
Click Insert Data.
The system automatically obtains 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
Retrieve data from a specific time series within a designated time frame.
For additional details on querying table data with SQL, see Using SQL to Query Time Series Data.
If you're uncertain of the details for the time series data you want to query, you can define multiple conditions to retrieve all time series that satisfy those conditions. For detailed instructions, see Retrieve Time Series.
-
On the Data Management tab of the time series table, click Query Data in the Actions column for the desired time series.
-
Specify the query conditions.
-
By default, query results are sorted chronologically. If you prefer to view data in reverse chronological order, set Reverse Query to Yes.
-
Choose a search method and define a time range.
-
-
Click Query.
The data matching the query conditions will be displayed on the Data Management tab, available in either list or graph format.
Retrieve time series
If you're uncertain about the details of the time series you want to query, such as the measurement and data source, you can set multiple criteria to retrieve all time series that match your specified conditions.
-
On the Data Management 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, and click Add in the corresponding area to establish the matching conditions for tags, properties, or update times as needed.
The conditions shown in the figure below are for querying all time series that include
car_model=model_A
in the tags. -
Click OK.
The data matching the query conditions will be displayed on the Data Management tab.
Sample scenarios
In the Internet of Vehicles scenario, vehicles transmit time series data to the cloud via sensors. By storing, querying, and analyzing this time series data, users can fulfill business requirements such as generating vehicle condition reports, tracking vehicle locations, managing traffic, and projecting travel paths. This topic illustrates the process of creating a time series table and executing data read and write operations using a time series table named car_example, which stores vehicle time series data (primarily vehicle trajectory information) in the Internet of Vehicles scenario. The structure of the table is outlined below:
Field Name | Data Type | Description |
_m_name | String | The measurement name, which indicates the name of the physical quantity or monitoring metric measured by the time series data. |
_data_source | String | The data source, which indicates the identifier of the data source that generates the time series. It can be empty. |
_tags | String | The tag of the time series. You can customize multiple key-value pairs of the string type. |
_time | Integer | The data reporting time. |
vin_id | String | The vehicle identification number (VIN), which is used to uniquely identify the vehicle. |
model | String | The vehicle model. |
speed | Double | The current speed. |
gps | String | The GPS coordinates of the vehicle, in the format of |
current_mileage | Double | The current mileage. |
remaining_oil | Double | The remaining oil volume. |
available_mileage | Double | The remaining available mileage. |
tire_pressure | Double | The tire pressure data. |