Tablestore SDK for Go provides a variety of operations on time series tables and time series data 、分析存储for the TimeSeries model.
The Tablestore TimeSeries model is designed based on the characteristics of time series data and is suitable for scenarios such as IoT device monitoring, device data collection, and machine data monitoring. For more information about the TimeSeries model, see Overview.
Operations on time series tables
To use the Tablestore TimeSeries model, you must call the CreateTimeseriesTable operation to create a time series table for storing time series data. For more information, see Create a time series table.
After you create a time series table, you can manage the time series table. The following table describes the operations that you can perform on time series tables.
|
Operation |
Description |
|
To view the existing time series tables in an instance, you can call the ListTimeseriesTable operation to query the names of all time series tables in the instance. |
|
|
To view the configuration details of a time series table, you can call the DescribeTimeseriesTable operation to query the information about the time series table, such as the time to live (TTL) of data. |
|
|
To clear historical data in a time series table or extend the retention period of data, you can call the UpdateTimeseriesTable operation to modify the TTL of data in the time series table. After you modify the TTL of data in a time series table, Tablestore automatically and asynchronously clears the data that exceeds the TTL in the time series table. |
|
|
If you no longer need to use a time series table to store time series data, you can call the DeleteTimeseriesTable operation to delete the time series table. Important
|
分析存储操作
为了低成本存储时序数据以及快速查询和分析时序数据,您可以为时序表创建分析存储。
分析存储功能主要用于时序数据长期存储和分析场景。更多信息,请参见时序分析存储概述。
-
创建时序表时,您可以同时创建分析存储。具体操作,请参见创建时序表。
-
创建时序表后,您可以使用CreateTimeseriesAnalyticalStore接口单独为已存在的时序表创建分析存储。具体操作,请参见创建分析存储。
创建分析存储后,您可以管理分析存储。具体操作说明请参见下表。
|
功能 |
描述 |
|
当需要查看分析存储的详细配置信息时,您可以使用DescribeTimeseriesAnalyticalStore接口查询分析存储描述信息,例如数据生命周期配置、数据同步选项、数据同步状态、数据存储大小等。 |
|
|
当需要清理分析存储中的历史数据或者希望延长数据保存时间时,您可以使用UpdateTimeseriesAnalyticalStore接口更新时序分析存储的数据生命周期TTL配置。更新分析存储的TTL后,Tablestore会自动异步清理分析存储中超过TTL的数据。 |
|
|
当不再需要使用分析存储来低成本存储以及查询与分析时序数据时,您可以使用DeleteTimeseriesAnalyticalStore接口删除时序表下的分析存储。 |
Operations on time series data
After you create a time series table, you can call the PutTimeseriesData operation to write multiple rows of time series data to the time series table at a time. For more information, see Write time series data.写入时序数据到时序表时,分析存储会自动同步时序表中的数据。
After time series data is written to a time series table, you can perform the following operations to query the time series data of a time series in the time series table:
-
If you are not sure about the information about the time series that you want to query, such as the metric name and data source, you can call the QueryTimeseriesMeta operation to specify multiple conditions to retrieve the time series. For more information, see Retrieve time series.
If the property information in time series metadata does not meet your requirements, you can update or delete the time series metadata.
Operation
Description
You can call the UpdateTimeseriesMeta operation to modify multiple properties in time series metadata at a time.
You can call the DeleteTimeseriesMeta operation to delete the metadata of multiple time series at a time.
-
You can call the GetTimeseriesData operation to query the time series data that meets specific conditions in a specific time series. For more information, see Query time series data.
After you write time series data to the time series table, if you want to use an analytical store to query and analyze the time series data in a time series, you can create a mapping table for the analytical store and execute the SELECT statement to query time series data. For more information, see SQL query examples.