You can access Tablestore in the Tablestore console, in the Tablestore CLI, or by using Tablestore SDKs. You can get started with Tablestore in the Tablestore console. This topic describes how to manage the TimeSeries model in the Tablestore console.

Prerequisites

Before you use Tablestore, make sure that you have an Alibaba Cloud account and you have completed the real-name verification. If you do not have an Alibaba Cloud account, the system prompts you to create an Alibaba Cloud account when you activate Tablestore.

Step 1: Activate Tablestore

If Tablestore is activated, skip this operation. You must activate Tablestore only once. You are not charged when you activate Tablestore.

  1. Log on to the Tablestore product page.
  2. Click Get it Free.
  3. On the Tablestore (Pay-as-you-go) page, click Buy Now.
  4. On the Confirm Order page, select I have read and agree to Tablestore (Pay-as-you-go) Agreement of Service and click Activate Now.
    After you activate Tablestore, click Management Console to access the Tablestore console.

    You can also click Console in the upper-right corner of the homepage. Click the fig_tablestore_control_001 icon. In the left-side navigation pane, choose Products and Services > Table Store to go to the Tablestore console.

Step 2: Create a public preview instance for the TimeSeries model

  1. Log on to the Tablestore console.
  2. In the top navigation bar, select China (Shanghai).
    The instance types that are available in the region are displayed in the console.
  3. Click Create Public Preview Instance for TimeSeries Model.
  4. In the Create Public Preview Instance for TimeSeries Model dialog box, specify Instance Name and Instance Description based on your business requirements.
    Notice Each Alibaba Cloud account can create up to 10 instances. The name of an instance must be unique within the region in which the instance resides.
  5. Click OK.

Step 3: Create a time series table

  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 4: Write data to the time series table

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 5: 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 6: 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

Step 7: Execute SQL statements to query time series data

SQL queries are compatible with the query syntax of MySQL. You can execute SQL statements to access data in time series tables.

  1. On the Overview page, click the name of the instance that you want to manage or click Manage Instance in the Actions column of the instance that you want to manage.
  2. On the Query by Executing SQL Statement tab, select a time series table from which you want to query data, and execute the SELECT statement to query data in the table.