After you connect Tablestore to Grafana, use Grafana to visualize the data in Tablestore.
Prerequisites
You have performed the following operations in the Resource Access Management (RAM) console:
You have created a RAM user and granted the RAM user the permissions to manage Tablestore (AliyunOTSFullAccess).
WarningIf the AccessKey pair of your Alibaba Cloud account is leaked, your cloud resources are at risk. We recommend that you use the AccessKey pair of a RAM user to perform operations. This reduces security risks if the AccessKey pair is leaked.
You have performed the following operations in the Tablestore console:
You have created a data table and a time series table.
You have created a mapping for the table and a mapping for the multi-value model.
You have installed open source Grafana. The Grafana version must be 8.0.0 or later. This topic uses Grafana v10.4.2 as an example. For more information, see the Grafana official documentation.
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 connect Tablestore to Grafana, use Grafana to generate dashboard panels based on the table data and display the data in real time.
Usage notes
Use Grafana to visualize Tablestore data in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Shenzhen), and Singapore.
Step 1: Install the Tablestore plug-in
Windows
Download the Grafana plug-in package for Tablestore.
Decompress the package and move the plug-in files to the plugins-bundled directory of your Grafana installation.
Modify the Grafana configuration file.
Use a text editor to open the defaults.ini configuration file in the conf directory.
In the [plugins] section of the configuration file, set the allow_loading_unsigned_plugins parameter.
allow_loading_unsigned_plugins = aliyun-tablestore-grafana-datasource
In Task Manager, restart the grafana-server.exe process.
Mac/Linux
Run the following command to download the Grafana plug-in package for Tablestore.
wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20220527/ygdf/tablestore-grafana-plugin-1.0.0.zipDecompress the package to the Grafana plug-in directory.
Run the command that corresponds to your Grafana installation method.
If you installed Grafana from a Yellowdog Updater, Modified (YUM) repository or an RPM Package Manager (RPM) package (Linux only): unzip tablestore-grafana-plugin-1.0.0.zip -d /var/lib/grafana/plugins
If you installed Grafana from a .zip file: unzip tablestore-grafana-plugin-1.0.0.zip -d {PATH_TO}/grafana-{VERSION}/data/plugins
NoteIn the command,
{PATH_TO}/grafana-{VERSION}specifies the installation path of Grafana, and{VERSION}specifies the version number of Grafana.
Modify the Grafana configuration file.
Open the configuration file.
If you installed Grafana from a YUM repository or an RPM package (Linux only): /etc/grafana/grafana.ini
If you installed Grafana from a .zip file: {PATH_TO}/grafana-{VERSION}/conf/defaults.ini
NoteIn the path,
{PATH_TO}/grafana-{VERSION}specifies the installation path of Grafana, and{VERSION}specifies the version number of Grafana.
In the [plugins] section of the configuration file, set the allow_loading_unsigned_plugins parameter.
allow_loading_unsigned_plugins = aliyun-tablestore-grafana-datasource
Restart Grafana.
Run the kill command to stop the Grafana process.
Run the command that corresponds to your installation method to start Grafana.
If you installed Grafana from a YUM repository or an RPM package (Linux only): systemctl restart grafana-server
If you installed Grafana from a .zip file: ./bin/grafana-server web
Step 2: Configure a data source
Log on to Grafana.
In a browser, enter
http://<x.x.x.x>:3000/to open the Grafana logon page.Note<x.x.x.x>specifies the IP address of the server where Grafana is deployed. For example, if Grafana is installed in a Windows environment, the logon address ishttp://localhost:3000.Enter your Email or username and Password, and then click Log in.
NoteThe default username and password are both admin. When you log on for the first time, you are prompted to change the password.
On the Grafana home page, click the
icon in the upper-left corner.In the navigation pane on the left, choose .
On the Data sources page, click + Add new data source.

On the Add data source page, in the Others section, click aliyun-tablestore-grafana-datasource.
On the Settings page, configure the parameters as described in the following table.
Parameter
Example
Description
Name
aliyun-tablestore-grafana-datasource
The name of the data source. You can enter a custom name. The default value is aliyun-tablestore-grafana-datasource.
Endpoint
https://myinstance.cn-hangzhou.ots.aliyuncs.com
The endpoint of the Tablestore instance. Enter the endpoint of the instance that you want to access. For more information, see Endpoints.
Instance
myinstance
The name of the Tablestore instance.
AccessId
************************
The AccessKey ID of the Alibaba Cloud account or RAM user that has permissions to access Tablestore.
AccessKey
********************************
The AccessKey secret of the Alibaba Cloud account or RAM user that has permissions to access Tablestore.
Click Save & test.
If the connection is successful, the Data source is working message is displayed.

Step 3: Create a dashboard panel
On the Grafana home page, click the
icon in the upper-left corner.In the navigation pane on the left, click Dashboards.
On the Dashboards page, click New and then select New dashboard.

On the New dashboard page, click + Add visualization.
In the Select data source dialog box, select the configured Tablestore data source.

On the Edit page, configure the query conditions in the Query section.
The following table describes the 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 1000The SQL query statement. For more information, see Query data.
ImportantIn the WHERE clause, you must use a predefined macro to filter data by time range, such as
$__unixMicroTimeRangeFilterin the example. To view more time macros, click "Show Help" on the configuration page.If you want to display data in a time series chart, the query must return a time column that is represented by a numeric timestamp. You must also configure the name of the time column.
Format As
Timeseries
The format of the results. Valid values:
Timeseries (Default): A standard time series chart.
FlowGraph: A multi-dimensional chart.
Table: A standard table.
Time Column
_time
The name of the time column in the returned data. The time column is used as the x-axis of the time series chart. This parameter is available when you set Format As to Timeseries or FlowGraph.
Aggregation Column
_field_name#:#_double_value
Converts multiple rows of single-column data at the same point in time into a single row of multi-column data. This is useful for converting single-value model data from a Tablestore time series SQL query into multi-value model data. This parameter is available when you set Format As to FlowGraph. The format is
<Data point name column>#:#<Value column>.Click Run SQL to execute the SQL statement and then view and debug the data.
Configure and save the dashboard panel.
In the right-side pane, set the name, type, and display style of the monitoring chart.

In the upper-right corner, click Apply.
In the upper-right corner, click Save. In the Save dashboard dialog box, set the Title, Description, and Folder parameters, and then click Save.
Step 4: View monitoring data
On the Grafana home page, click the
icon in the upper-left corner.In the navigation pane on the left, choose Dashboards. Click the dashboard in the destination folder to view all its monitoring charts.