All Products
Search
Document Center

Tablestore:Connect Tablestore to DataV-Board 6.0

Last Updated:Aug 27, 2024

After you add a Tablestore data source in the DataV console, you can use DataV to display Tablestore data.

Prerequisites

  • The following operations are performed in the Resource Access Management (RAM) console:

    • A RAM user is created and the AliyunOTSFullAccess and AliyunDataVFullAccess policies are attached to the RAM user. For more information, see Create a RAM user and Grant permissions to a RAM user.

      Warning

      If the AccessKey pair of your Alibaba Cloud account is leaked, your resources are exposed to potential risks. We recommend that you use the AccessKey pair of a RAM user to perform operations. This prevents the AccessKey pair of your Alibaba Cloud account from being leaked.

    • An AccessKey pair is created for the RAM user. For more information, see Create an AccessKey pair.

  • The following operations are performed in the Tablestore console:

  • The following operation is performed in the DataV console:

    DataV is activated. For more information, see Activate DataV.

Background information

DataV can convert statistical data to a variety of dynamic visual charts. For more information, see What is DataV? After you add a Tablestore data source to DataV, DataV displays real-time data on a dashboard based on the data of Tablestore tables.

Usage notes

  • Only the Wide Column model of Tablestore is supported. For more information, see Overview.

  • Tablestore data sources support only data tables and secondary indexes.

Step 1: Add a Tablestore data source

  1. Log on to the DataV console.

  2. On the Data Sources tab, click Data Sources. Then, click Add Source.

  3. In the Add Data dialog box, select TableStore from the Type drop-down list.

    ch-1

  4. Then, configure other parameters for a Tablestore data source. The following table describes the parameters.

    Parameter

    Description

    Name

    The display name of the data source.

    AK ID

    The AccessKey ID of your Alibaba Cloud account or a RAM user that has permissions to access Tablestore.

    AK Secret

    The AccessKey secret of your Alibaba Cloud account or a RAM user that has permissions to access Tablestore.

    Internet

    The endpoint of the Tablestore instance that you want to access. For more information, see Endpoints.

  5. Click OK.

    The data source that you added is displayed in the data source list.

Step 2: Configure the Tablestore data source

  1. Log on to the DataV console.

  2. On the Projects tab, create a visualization project or select an existing visualization project based on your business requirements.

    • If you use an existing visualization project, move the pointer over the visualization project and click Edit.fig_20220425_datavproject

    • If you use DataV for the first time or the existing visualization projects do not meet your requirements, you can create visualization projects based on your business requirements.

      Note

      You can create visualization projects on a PC or mobile device, or by using image recognition. The following example shows how to create a visualization project on a PC.

      1. Click PC Creation.

      2. On the page that appears, move the pointer over the template based on which you want to create a project and click Create Project.

        DataV allows you to create a visualization project by using a template or a blank canvas. You can select a method to create a visualization project based on your business requirements.

      3. In the Create Project dialog box, configure the Project Name and Project Group parameters and click Create.

        fig_20220424_createproject

  3. Configure the Tablestore data source.

    1. On the canvas editing page, click a widget on the canvas.

      Note

      If no widget exists on the canvas, add a widget first. For more information, see Add a widget.

    2. In the right-side widget configurations panel of the canvas, click the fig_data icon.

    3. On the Data tab, click Configure Data Source.

      fig_datasource11

    4. In the panel that appears, select TableStore from the Data Source Type drop-down list.

    5. In the Select an existing data source drop-down list, select the configured Tablestore data source.

    6. In the Select Action drop-down list, select the operation that you want to perform.

      The following operations are supported:

      • getRow: corresponds to the GetRow operation of Tablestore. For more information, see GetRow.

      • getRange: corresponds to the GetRange operation of Tablestore. For more information, see GetRange.

      • SQL: corresponds to the SQL query feature of Tablestore.

    7. In the code editor of the Select Action section, enter a query statement.

      getRow

      • The values of query parameters must be JSON objects.

      • If you select getRow, a row whose primary key is specified is read.

        The following sample code and table describe the request syntax and the parameters that you can configure for a query statement.

        {
            "table_name": "test",
            "rows": {
                "id": 1,
                "pk": "1",
            },
            "columns": [
                "id",
                "pk",
                "test"
            ]
        }

        Parameter

        Description

        table_name

        The name of the table whose data you want to read.

        rows

        The primary key information about the row.

        Important

        You must specify the same number and data types of primary key columns as the number and data types of primary key columns in the table.

        columns

        The names of the columns whose data you want to read.

      getRange

      • The values of query parameters must be JSON objects.

      • If you select getRange, all data whose primary key values are within the specified range is read. The following sample code and table describe the request syntax and the parameters that you can configure for a query statement.

        {
            "table_name": "test",
            "direction": "FORWARD",
            "columns": [
                "id",
                "test"
            ],
            "range": {
                "limit": 4,
                "start": {
                    "id": "InfMin"
                },
                "end": {
                    "id": "3"
                }
            }
        }

        Parameter

        Description

        table_name

        The name of the table whose data you want to read.

        direction

        The order in which you want to sort the rows in the response.

        • If you set this parameter to FORWARD, the start primary key value must be smaller than the end primary key value, and the rows in the response are sorted in ascending order of primary key values.

        • If you set this parameter to BACKWARD, the start primary key value must be greater than the end primary key value, and the rows in the response are sorted in descending order of primary key values.

        For example, you want to read data in a table and you use A and B as the start and end primary keys of the range to read. The value of A is smaller than the value of B. If you set the direction parameter to FORWARD, the rows whose primary key values are greater than or equal to the value of A but smaller than the value of B are returned in ascending order. If you set the direction parameter to BACKWARD, the rows whose primary key values are smaller than or equal to the value of B but greater than the value of A are returned in descending order.

        columns

        The columns whose data you want to read. You can specify the names of primary key columns or attribute columns.

        If you do not specify a column, all data of rows is returned.

        If the primary key of a row is in the specified range but the row does not contain data of the specified columns, the row is not returned.

        limit

        The maximum number of rows that can be returned. The value of this parameter must be greater than 0.

        An operation stops after the maximum number of rows that can be returned in ascending or descending order is reached, even if some rows in the specified range are not returned.

        start

        The start and end primary keys of the range to read. The start and end primary keys must be valid primary keys or virtual points that consist of data of the InfMin and InfMax types. The number of columns for each virtual point must be the same as the number of columns of each primary key.

        A value of the InfMin type is an infinitely small value. All values of other types are greater than the value of the InfMin type. A value of the InfMax type is an infinitely great value. All values of other types are smaller than the value of the InfMax type.

        Important

        You must specify the same number and data types of primary key columns as the number and data types of primary key columns in the table.

        • start indicates the start primary key. Rows that contain the start primary key are returned.

        • end indicates the end primary key. Rows that contain the end primary key are not returned.

        end

      SQL

      Use custom SQL statements to query data.

    8. Click Preview Responses of Data Source to view the response.

  4. Preview and publish the project.

    1. In the upper-right corner of the canvas editor, click the yulan icon to preview the project.

    2. In the upper-right corner of the canvas editor, click the fabu icon to publish the project.

      1. In the Publish dialog box, click Publish Project.

      2. Close the Published message.

        Note

        After the project is published, the content on the publish page is locked. After you edit the content, you can synchronize the published content by using the snapshot management feature. You can also click Manage Snapshots to view information about snapshots that are created.

      3. Click the figcopy icon next to the URL in the Sharing URL section to copy the URL.

        image

      4. Paste the URL to the address bar of a browser to view the published project.

Billing

Tablestore

You are charged based on the pay-as-you-go billing method when you use Tablestore resources. This billing method indicates that you are charged for the Tablestore resources that you used on an hourly basis. For more information, see Billing overview.

DataV

You are charged based on the subscription billing method when you use DataV resources. You can purchase DataV for a minimum of one month. You can select the edition and duration based on your business requirements. For more information, see Billing method.

FAQ

What do I do if data whose primary keys are out of the specified range is returned when the GetRange operation is called to read data?

References

You can connect Tablestore to Grafana to display Tablestore data. You can use Grafana to display time series table data of the TimeSeries model. For more information, see Connect Tablestore to Grafana.