Add and use a Tablestore data source

Updated at:

Managed Service for Grafana includes a built-in plugin for Alibaba Cloud Tablestore. This plugin lets you synchronize data from Tablestore and visualize it in real time on a Grafana dashboard. This topic describes how to add the Tablestore data source and create a dashboard panel.

Background information

Tablestore is a multi-model structured data storage service developed by Alibaba Cloud. It provides storage for large-scale structured data and offers fast query and analytics capabilities. With its distributed storage and powerful indexing engine, Tablestore supports petabytes of storage, tens of millions of transactions per second (TPS), and millisecond-level latency. For more information, see What is Tablestore.

Prerequisites

  • A Grafana workspace is created.

  • If you are using Grafana 11.4.x, you must enable the Tablestore data source because AngularJS is disabled by default in this version.

    1. Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management.

    2. On the Workspace Management page, click the ID of the target Grafana 11.4.x workspace.

    3. In the left-side navigation pane, click Parameter Settings. Click Modify Parameters, set security > angular_support_enabled to true, and then click Save and Apply.

Step 1: Log on to Grafana

  1. Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management.

  2. On the Workspace Management page, find the workspace that you want to manage and click the URL in the URL column to go to Grafana.

    Note

    You can log on to Grafana with the administrator account of Grafana and the password that you configured when you created the workspace. You can also click Sign in with Alibaba Cloud to log on to Grafana with the current Alibaba Cloud account.

Step 2: Configure the data source

Grafana 11.x

  1. In the left-side navigation pane, choose Connect > Data Source.

  2. Click Add data source in the middle of the page.

  3. On the Add data source page, search for and click aliyun-tablestore-grafana-datasource.

  4. On the Settings tab, set the following parameters.

    Parameter

    Description

    Name

    A custom name for the data source, such as aliyun-tablestore-grafana-datasource.

    Endpoint

    The endpoint of the Tablestore instance. For more information, see Obtain an endpoint.

    Instance

    The name of the Tablestore instance.

    AccessId

    The AccessKey ID of the Alibaba Cloud account used to access Tablestore. For more information, see Obtain an AccessKey pair.

    AccessKey

    The AccessKey secret of the Alibaba Cloud account used to access Tablestore. For more information, see Obtain an AccessKey pair.

  5. Click Save & test.

    If the Data source is working message appears, the data source is added.

Grafana 10.0.x

  1. On the Grafana homepage, click the image icon.

  2. In the left-side navigation pane, choose Management > Data sources.

  3. On the Data Source tab, click + Add new data source.

  4. On the Add data source page, search for and click aliyun-tablestore-grafana-datasource.

  5. On the Settings tab, set the following parameters.

    Parameter

    Description

    Name

    A custom name for the data source, such as aliyun-tablestore-grafana-datasource.

    Endpoint

    The endpoint of the Tablestore instance. For more information, see Obtain an endpoint.

    Instance

    The name of the Tablestore instance.

    AccessId

    The AccessKey ID of the Alibaba Cloud account used to access Tablestore. For more information, see Obtain an AccessKey pair.

    AccessKey

    The AccessKey secret of the Alibaba Cloud account used to access Tablestore. For more information, see Obtain an AccessKey pair.

  6. Click Save & test.

    If the Data source is working message appears, the data source is added.

Grafana 9.0.x

  1. In the left-side navigation pane, choose image > Data sources, and then click Add data source.

  2. On the Add data source page, search for and click aliyun-tablestore-grafana-datasource.

  3. On the Settings tab, set the following parameters.

    Parameter

    Description

    Name

    A custom name for the data source, such as aliyun-tablestore-grafana-datasource.

    Endpoint

    The endpoint of the Tablestore instance. For more information, see Obtain an endpoint.

    Instance

    The name of the Tablestore instance.

    AccessId

    The AccessKey ID of the Alibaba Cloud account used to access Tablestore. For more information, see Obtain an AccessKey pair.

    AccessKey

    The AccessKey secret of the Alibaba Cloud account used to access Tablestore. For more information, see Obtain an AccessKey pair.

  4. Click Save & test.

    If the Data source is working message appears, the data source is added.

Step 3: Create a dashboard panel

Grafana 11.x

  1. In the left-side navigation pane, click Dashboards. In the upper-right corner, click Create > New dashboard.

  2. On the New dashboard page, click + Add visualization.

  3. On the Select data source page, select the data source that you added in Step 2.

  4. Configure the query settings as described in the following table, and then click Run SQL.

    Parameter

    Example

    Query

    The SQL query to execute. For more information, see the Tablestore documentation.

    Sample SQL query:

    SELECT
      *
    FROM
      your_table
    WHERE
      $__unixMicroTimeRangeFilter(_time)
      AND _m_name = "your_measurement"
      AND tag_value_at(_tags, "your_tag")="your_tag_value"
    LIMIT 1000
    Note
    • In the WHERE clause, use a predefined macro such as $__unixMicroTimeRangeFilter to filter by time range. For more information about time macros, see Use SQL to query time-series data.

    • To display data in a time series chart, the query must return a numeric timestamp column, and you must specify the column's name.

    Format As

    The format for the query results:

    • Timeseries: A standard time series chart.

    • FlowGraph: A multi-dimensional chart.

    • Table: A standard table.

    Time Column

    The name of the time column in the query results, which is used for the x-axis.

    Aggregation Column

    This parameter is required only when Format As is set to FlowGraph. It converts multiple rows of single-column data at the same timestamp into a single row of multi-column data. This is particularly useful for converting single-value model data from Tablestore time series SQL into multi-value model data. The format is <data_point_name_column>#:#<value_column>. Example: "_field_name#:#_double_value".

  5. In the upper-right corner, click Save dashboard. Set the dashboard name and folder, and then click Save.

Grafana 10.0.x

  1. On the Grafana homepage, click the image icon.

  2. In the left-side navigation pane, click Dashboards. On the page that appears, select New dashboard from the New drop-down list.

  3. On the New dashboard page, click + Add visualization.

  4. In the Select data source pop-up window, select the data source that you added in Step 2.

  5. Configure the query settings as described in the following table, and then click Run SQL.

    Parameter

    Example

    Query

    The SQL query to execute. For more information, see the Tablestore documentation.

    Sample SQL query:

    SELECT
      *
    FROM
      your_table
    WHERE
      $__unixMicroTimeRangeFilter(_time)
      AND _m_name = "your_measurement"
      AND tag_value_at(_tags, "your_tag")="your_tag_value"
    LIMIT 1000
    Note
    • In the WHERE clause, use a predefined macro such as $__unixMicroTimeRangeFilter to filter by time range. For more information about time macros, see Use SQL to query time-series data.

    • To display data in a time series chart, the query must return a numeric timestamp column, and you must specify the column's name.

    Format As

    The format for the query results:

    • Timeseries: A standard time series chart.

    • FlowGraph: A multi-dimensional chart.

    • Table: A standard table.

    Time Column

    The name of the time column in the query results, which is used for the x-axis.

    Aggregation Column

    This parameter is required only when Format As is set to FlowGraph. It converts multiple rows of single-column data at the same timestamp into a single row of multi-column data. This is particularly useful for converting single-value model data from Tablestore time series SQL into multi-value model data. The format is <data_point_name_column>#:#<value_column>. Example: "_field_name#:#_double_value".

  6. Click Apply.

  7. In the upper-right corner, click the Save dashboard icon. Then, specify the name of the dashboard and the directory in which the dashboard resides.

Grafana 9.0.x

  1. In the left-side navigation pane of Grafana, choose image > New dashboard.

  2. On the New dashboard page, click Add a new panel.

  3. On the Query tab of the Edit Panel page, select your data source from the Data source drop-down list.

  4. Configure the parameters as described in the following table, and then click Run SQL.

    Parameter

    Example

    Query

    The SQL query to execute. For more information, see the Tablestore documentation.

    Sample SQL query:

    SELECT
      *
    FROM
      your_table
    WHERE
      $__unixMicroTimeRangeFilter(_time)
      AND _m_name = "your_measurement"
      AND tag_value_at(_tags, "your_tag")="your_tag_value"
    LIMIT 1000
    Note
    • In the WHERE clause, use a predefined macro such as $__unixMicroTimeRangeFilter to filter by time range. For more information about time macros, see Use SQL to query time-series data.

    • To display data in a time series chart, the query must return a numeric timestamp column, and you must specify the column's name.

    Format As

    The format for the query results:

    • Timeseries: A standard time series chart.

    • FlowGraph: A multi-dimensional chart.

    • Table: A standard table.

    Time Column

    The name of the time column in the query results, which is used for the x-axis.

    Aggregation Column

    This parameter is required only when Format As is set to FlowGraph. It converts multiple rows of single-column data at the same timestamp into a single row of multi-column data. This is particularly useful for converting single-value model data from Tablestore time series SQL into multi-value model data. The format is <data_point_name_column>#:#<value_column>. Example: "_field_name#:#_double_value".

  5. Click Apply.

  6. In the upper-right corner, click the Save dashboard icon. Then, specify the name of the dashboard and the directory in which the dashboard resides.

  7. Click Save.

Step 4: View the monitoring data

Grafana 11.x

In the left-side navigation pane, click Dashboards. Click a dashboard in the target folder to view its monitoring charts.

Grafana 10.0.x

  1. On the Grafana home page, click the image icon in the upper-left corner.

  2. In the left-side navigation pane, select Dashboards. Click a dashboard in the target folder to view its monitoring charts.

Grafana 9.0.x

  1. In the left-side navigation pane, choose image > Browse.

  2. On the Browse tab, click a dashboard in the target folder to view its monitoring charts.