After you create a time series table in the console, you can write time series data to the time series table, and retrieve time series and query time series data in the time series table.

Prerequisites

A public preview instance for the TimeSeries model is created. For more information, see Create a public preview instance for the TimeSeries model.

Public preview

The TimeSeries model is in public preview in the China (Shanghai), China (Hangzhou), and China (Shenzhen) regions. During the public preview, you can use the TimeSeries model free of charge. To get started with the TimeSeries model, you can log on to the Tablestore console and click Create Public Preview Instance for TimeSeries Model to create a public preview instance for the TimeSeries model. For more information, see Create a public preview instance for the TimeSeries model.

After you create a public preview instance for the TimeSeries model, you can use the Tablestore console, CLI, or SDKs to get started with the TimeSeries model. For more information, see Use the Tablestore console, Use the Tablestore CLI, and Use Tablestore SDKs.

If you have questions, please join the Tablestore technical support group by searching for group ID 11789671 or 23307953 in DingTalk to contact us.

Step 1: Create a time series table

Create a time series table in the Tablestore console.

  1. Log on to the Tablestore console.
  2. On the Overview page, click the name of the instance in which you want to create a time series table or click Manage Instance in the Actions column that corresponds to the instance.
  3. On the Instance Details tab, click the Time Series Tables tab.
  4. On the Time Series Tables tab, click Create Time Series Table.
    Note You can also click Generate Demo with One Click to create a test table with sample data for a quick start. When you create a time series table, the system performs some initialization operations. Therefore, you need to wait for dozens of seconds until the time series are displayed.
  5. In the Create Time Series Table dialog box, specify Name and Time to Live as described in the following table.
    Parameter Description
    Name The name of the time series table, which is used to identify the time series table in an instance.

    The name must be 1 to 128 characters in length and can contain letters, digits, and underscores (_). The name must start with a letter or an underscore (_).

    The name of a time series table cannot be the same as the name of an existing data table.

    Time to Live The retention period of the data in the time series table. Unit: seconds. If the system detects that the difference between the current time and the time column that is passed to the table exceeds the specified TTL value, the system automatically deletes the expired data.
    Notice In the time series table, the system determines the time when the data is generated based on the time column that is passed to the table, not the time when the data is written to the table.

    The value of this parameter must be -1 or a value that is greater than or equal to 86400 seconds (one day).

  6. Click OK.

    After the time series table is created, you can view the time series table on the Time Series Tables tab. If the time series table is not displayed in the list of time series tables, click the fig_tablestore_002 icon to refresh the list of time series tables.

Step 2: Write time series data

Write time series data to the time series table in the Tablestore console. 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.

  1. On the Time Series Tables tab, click the name of the time series table and then click the Query Data tab or click Manage Data in the Actions column that corresponds to the time series table.
  2. (Optional) Create a time series.
    1. On the Query Data tab, click Add Timeline.
    2. In the Add Timeline dialog box, configure the metadata of the time series.
      fig_datatimeseries
      The following table describes the parameters that you can configure to add a time series.
      Parameter Description
      Metric Name The name of a physical quantity or metric for the data in the time series, such as cpu or net, which specifies 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 The property column of the time series, which is used to record some property information of the time series.
    3. Click OK.
  3. Insert data.
    1. Click Insert Data.
    2. In the Insert Data dialog box, specify Time and Attribute Column. fig_datatimeseries
    3. Click OK.

Step 3: Retrieve time series

Retrieves all the time series that meet the specified conditions.

  1. On the Query Data tab, click Query Data in the upper-right corner.
  2. In the Query Data dialog box, specify Metric Name and Data Source, and click Add in the Tag, Property, and Updated At sections to add conditions.
    The following figure shows an example on how to query the time series in which the metric name is cpu and the tags contain os=Ubuntu16.10. fig_querytimeseries
  3. Click OK.

    The time series that meet the conditions are displayed on the Query Data tab.

Step 4: Query time series data

Query the data in a time series within a specific time range.

  1. On the Query Data tab, click Query Data in the Actions column that corresponds to the time series whose data you want to query.
  2. Select Time Range or Microsecond Timestamp from the drop-down list of Search Method, specify the time, and click Search.

    The data that meets the conditions is displayed on the Query Data tab. The query results can be displayed in a list or figure.

    The following figure shows an example of the query results in a list.fig_timeseriesdataquery
    The following figure shows an example of the query results in a figure.
    Note Different colors in the figure represent different data columns. If you move the pointer over the data trend line, the values of the corresponding data columns are displayed. You can also select or clear specific data columns to display the required data columns.
    fig_picdisplay