After Tablestore is connected to Grafana, you can use Grafana to display Tablestore data.

Prerequisites

Background information

Grafana is an open source visualization and analytics platform that supports data query and visualization for various data sources such as Prometheus, Graphite, OpenTSDB, InfluxDB, Elasticsearch, MySQL, and PostgreSQL. For more information, see the Grafana official documentation.

After you add a Tablestore data source to Grafana, Grafana displays real-time data on a dashboard based on the data of Tablestore.

Usage notes

The support for Grafana is available in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), and Singapore (Singapore).

Step 1: Install the Grafana plug-in for Tablestore

Windows

  1. Click Grafana plug-in for Tablestore package to download the Grafana plug-in for Tablestore package.
  2. Extract files from the package to the plugins-bundled directory of the Grafana plug-in.
  3. Modify the configuration file of Grafana.
    1. Use a text editor to open the defaults.ini configuration file in the conf directory of the Grafana plug-in.
    2. Find [plugins] in the configuration file and configure the allow_loading_unsigned_plugins parameter.
      allow_loading_unsigned_plugins = aliyun-tablestore-grafana-datasource
  4. Restart the grafana-server.exe process in Task Manager.

Linux or macOS

  1. Run the following command to download the Grafana plug-in for Tablestore package:
    wget https://tablestore-doc.oss-cn-hangzhou.aliyuncs.com/aliyun-tablestore-grafana-plugin/tablestore-grafana-plugin-1.0.0.zip
  2. Extract files from the Grafana plug-in for Tablestore package to a directory of the Grafana plug-in.
    Run the following command to extract files from the Grafana plug-in for Tablestore package based on the method that is used to install the Grafana plug-in.
    • If you use a yum repository or an RPM package to install the Grafana plug-in in Linux, run the unzip tablestore-grafana-plugin-1.0.0.zip -d /var/lib/grafana/plugins command.
    • If you use a .tar.gz file to install the Grafana plug-in, run the unzip tablestore-grafana-plugin-1.0.0.zip -d {PATH_TO}/grafana-{VERSION}/data/plugins command.
  3. Modify the configuration file of Grafana.
    1. Go to the directory of Grafana and open the configuration file.
      • If you use a yum repository or an RPM package to install Grafana in Linux, open the /etc/grafana/grafana.ini file.
      • If you use a .tar.gz file to install Grafana, open the {PATH_TO}/grafana-{VERSION}/conf/defaults.ini file.

        In the preceding file name, {PATH_TO}/grafana-{VERSION} indicates the installation path of Grafana and VERSION indicates the version number of Grafana.

    2. Find [plugins] in the configuration file and configure the allow_loading_unsigned_plugins parameter.
      allow_loading_unsigned_plugins = aliyun-tablestore-grafana-datasource
  4. Restart Grafana.
    1. Run the kill command to terminate the Grafana process.
    2. Run the following command to start Grafana.
      • If you use a yum repository or an RPM package to install Grafana, run the systemctl restart grafana-server command.
      • If you use a .tar.gz file to install Grafana, run the ./bin/grafana-server web command.

Step 2: Add a data source

  1. Log on to Grafana.
    1. Open a browser and enter http://localhost:3000/ in the address box to go to the Grafana logon page.
    2. Enter values for the Email or username and Password parameters, and click Log in.
      The default username and password that are used to log on to Grafana are both admin. The first time you log on to Grafana, change the default password as prompted.
  2. Move the pointer over the fig_config icon in the left-side navigation pane and click Data sources.
  3. On the Data sources tab, click Add data source.
  4. In the Others section of the Add data source page, click aliyun-tablestore-grafana-datasource.
  5. On the Settings page, configure the parameters. The following table describes the parameters.
    Parameter Example Description
    Name aliyun-tablestore-grafana-datasource The name of the data source. You can retain the default value or enter a custom name. Default value: aliyun-tablestore-grafana-datasource.
    Endpoint https://myinstance.cn-hangzhou.ots.aliyuncs.com The endpoint of the Tablestore instance. Configure this parameter based on the Tablestore instance that you want to access. For more information, see Endpoint.
    Instance myinstance The name of the Tablestore instance.
    AccessId ************************ The AccessKey ID of your Alibaba Cloud account or a RAM user that has permissions to access Tablestore.
    AccessKey ******************************** The AccessKey secret of your Alibaba Cloud account or a RAM user that has permissions to access Tablestore.
  6. Click Save & test.
    After the data source is added to Grafana, the Data source is working message appears. fig_20220425_setting

Step 3: Create a dashboard panel

  1. In the Grafana console, move the pointer over the fig_20220425_add icon in the left-side navigation pane and click Dashboard.
  2. On the New dashboard page, click the fig_20220425_adddashboard icon.
  3. In the Add panel section, click Add a new panel.
  4. In the Query section of the Edit Panel page, specify the conditions that are used to query data from the data source.
    1. Select a Tablestore data source from the Data source drop-down list.
    2. Configure the data source parameters.
      Parameter Example Description
      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 The SQL query statement. For more information, see Query data.
      Notice
      • In the WHERE clause, the time range condition that is used to filter data is specified by using a predefined macro. In this example, the predefined macro is $__unixMicroTimeRangeFilter. You can click Show Help on the configuration page to view more time macro functions.
      • If you want data to be displayed as a time series chart, you must specify that the time column that is represented by a numeric timestamp must be returned and specify the name of the time column.
      Format As Timeseries The method that you want to use to display the query results. Default value: Timeseries. Valid values:
      • Timeseries: displays the query results as a regular time series chart.
      • FlowGraph: displays the query results as a multi-dimensional chart.
      • Table: displays the query results as a regular table.
      Time Column _time The name of the time column in the query results that are returned. The time column is used as the x-axis of the time series chart. If you set the Format As parameter to Timeseries or FlowGraph, you can configure this parameter.
      Aggregation Column _field_name#:#_double_value The name of the single column whose data in multiple rows at a specified point in time you want to convert into data in multiple columns of a single row at the specified point in time. This parameter is used if you want to convert data in single-value model to data in multi-value model. The data in single-value model is the results that are obtained when you use SQL to query a time series table in Tablestore. If you set the Format As parameter to FlowGraph, you can configure this parameter. The value of this parameter is in the <Data point name column>#:#<Data value column> format.
  5. Click Run SQL to execute SQL statements, view the data, and then perform debugging.
  6. Configure the dashboard panel and save the configurations.
    1. On the right side of the page, specify the name, type, and layout of the monitoring chart.
      fig_20220426_dashboard
    2. In the upper-right corner, click Apply.
    3. Click the fig_20220426_savedashboard icon in the upper-right corner. In the Save dashboard as... dialog box, configure the Dashboard name and Folder parameters and click Save.

Step 4: View monitoring data

  1. In the Grafana console, move the pointer over the fig_20220426_view icon in the left-side navigation pane and click Browse.
  2. On the Browse tab, click the monitoring dashboard under the folder that you specified for the dashboard to view all monitoring charts on the dashboard.