Grafana is an open-source tool for visualizing large-scale metric data. It is widely used for internet application analysis and is popular in fields such as industrial monitoring, weather monitoring, home automation, and process management.Lindorm provides an Alibaba Cloud Lindorm data source plugin that allows you to add Lindorm as a data source in Grafana. This topic describes how to connect to LindormTSDB for visual data analysis.
Using Managed Service for Grafana
Prerequisites
-
A Grafana workspace is created. For more information, see Create a Grafana workspace.
-
If you want to connect to LindormTSDB over the internet, complete the following steps:
-
Enable a public address for your LindormTSDB instance. For more information, see View the connection information of LindormTSDB.
-
Add the public IP address of Grafana to the Lindorm whitelist. For more information, see Configure a whitelist.
-
Procedure
This section uses Grafana 10.0.x as an example.
-
Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management.
-
In the Basic Information section, click the public or private address to open the Grafana UI. Enter your username and password to log in. The username is admin, and the password is the one you set when creating the workspace.
-
Add a Lindorm data source in Grafana.
-
Click the
icon in the upper-left corner and select Manage. Then, click Data sources. -
On the Data sources page, click Add data source.
-
This opens the page for adding a new data source.
-
On the Add data source page, search for
Alibaba Cloud Lindormand click it. -
On the Settings tab, configure the following parameters. Leave other parameters at their default values.
Setting
Parameter
Required
Description
Name
Yes
A custom name for the data source.
HTTP
URL
Yes
The HTTP endpoint of LindormTSDB. For more information, see View the connection information of LindormTSDB.
ImportantUse the public address of LindormTSDB and add the public IP address of Grafana to the Lindorm whitelist.
Auth
Basic auth
No
If user authentication is enabled for LindormTSDB, enable Basic auth and enter the username and password for LindormTSDB in the Basic Auth Details section. For more information about user authentication, see Manage users and permissions.
Basic auth details
User
No
The username for LindormTSDB. Required only if Basic auth is enabled.
Password
No
The password for LindormTSDB. Required only if Basic auth is enabled.
Lindorm TSDB details
Database
No
The LindormTSDB database that you want to access.
-
Click Save & test.
A "test success" message indicates that the connection is successful.
-
-
Click Build a dashboard.
-
On the New Dashboard page, click Add visualization.
-
Select the Lindorm data source that you added in Step 3.
-
On the Query tab, configure your query.
-
From the Data source list, select your data source.
-
Grafana provides two query editor modes: the template-based query editor and the SQL statement editor.
SQL statement editor
Click the
icon in the upper-right corner of section A to switch to the raw query editor. You can then enter Lindorm SQL statements to perform complex queries. For example:SELECT region,time,avg(temperature) FROM sensor WHERE time >= $from AND time <= $to SAMPLE BY $intervalNoteFor more information about Lindorm SQL syntax, see SELECT syntax.
-
The time condition
time >= $from AND time <= $tois mandatory; otherwise, the query will fail. The parameter values are automatically replaced with the time range selected on the dashboard. -
Under Query options, use the Min interval and Max data points settings to adjust the Interval.
-
Use ALIAS BY to rename a time series label. The format is
$tag_<tag_name>. For example, if you use$tag_host, the time series label displays the value of thehosttag. -
Use OFFSET to set a time offset, which helps you compare data from different time periods.
Template-based query editor
You can perform simple queries by using a template to select the table, fields, and query conditions. The following table describes the keywords.
Keyword
Description
SELECTSelect the field names to query.
FROMSelect the table name to query.
WHEREAdd query conditions.
GROUP BYAdd aggregation conditions.
SAMPLE BYSelect the time interval for downsampling. For more information, see Downsampling queries.
Click Query options to adjust the Interval parameter by using the Min interval and Max data points settings.
ORDER BY TIMESort the query results by time.
LIMITSpecify the number of rows to return in the result set.
ALIAS BYRename a time series label. The format is
$tag_<tag_name>. For example, if you use$tag_host, the time series label displays the value of thehosttag.OFFSETSet a time offset, which helps you compare data from different time periods.
-
-
Using a self-managed Grafana on ECS
Deployment requirements
-
The ECS instance must use CentOS 7.3 64-bit or later.
-
The ECS instance must have at least 1 vCPU, 2 GB of memory, and 10 GB of available disk space.
Prerequisites
Before you begin, make sure you have completed the following:
-
Add an inbound rule to the security group of the ECS instance to allow traffic on port 3000. For more information, see Add a security group rule.
-
Add the IP address of the ECS instance to the Lindorm whitelist.
If the ECS instance and the Lindorm instance are in the same VPC: Add the primary private IP address of the ECS instance to the Lindorm instance whitelist. For more information, see Configure a whitelist.
If the ECS instance and the Lindorm instance are not in the same VPC:
-
Assign a public IP address to the ECS instance. If the ECS instance does not have a public IP address, associate an EIP with a cloud resource or change the bandwidth configuration.
-
Add the public IP address of the ECS instance to the Lindorm instance whitelist. For more information, see Configure a whitelist.
-
-
If you access the Grafana web UI over the internet, make sure the ECS instance has a public IP address. If it does not, associate an EIP with a cloud resource or change the bandwidth configuration. A public IP address is not required if you access the Grafana web UI over a VPC.
Procedure
-
Install Grafana. If Grafana is already installed, skip this step.
-
Log on to the ECS instance. For more information, see Connect to an ECS instance.
-
Run the following command to download Grafana:
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.2.2-1.x86_64.rpmNoteThis example uses Grafana Enterprise Edition 8.2.2-1. You can install other versions. For more download addresses, see the official Grafana website.
-
Run the following command to install Grafana:
sudo yum install grafana-enterprise-8.2.2-1.x86_64.rpm -
Run the following command to start the Grafana service:
sudo service grafana-server start
-
-
Install the Alibaba Cloud Lindorm data source plugin.
-
Run the following command to download the Lindorm data source plugin package. Select the correct download link for your Grafana version.
-
For Grafana 11.0 and later:
wget https://hbaseuepublic.oss-cn-beijing.aliyuncs.com/grafana-alibabacloud-lindorm-datasource-11.0.1.zip-
For Grafana 10.x and earlier:
wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/grafana-alibabacloud-lindorm-datasource-latest.zip -
-
Run the following command to extract the plugin to the default directory. In Linux, the default directory is /var/lib/grafana/plugins/.
unzip grafana-alibabacloud-lindorm-datasource-latest.zip -d /var/lib/grafana/plugins/ -
Run the following command to edit the grafana.ini file. In Linux, the default file path is /etc/grafana/grafana.ini.
sudo nano -w /etc/grafana/grafana.ini -
In the [plugins] section, change
;allow_loading_unsigned_plugins=toallow_loading_unsigned_plugins = alibabacloud-lindorm-datasource. After the modification, press CTRL+O to save the file and press Enter to exit the editor.ImportantWhen you edit the grafana.ini file, you must remove the semicolon (;) from the beginning of
;allow_loading_unsigned_plugins. -
Run the following command to restart the Grafana service:
sudo service grafana-server restart
-
-
Add a Lindorm data source in Grafana.
-
In a web browser, go to
http://IP:3000/, whereIPis the public IP or primary private IP address of your ECS instance. Enter your username and password. The default username and password for the first login are both admin. We recommend changing your password immediately after logging in. For more details, see Sign in to Grafana. -
Click the
icon in the left-side navigation pane and select Data Sources. -
On the Configuration page, click Add data source.
-
On the Add data source page, search for Alibaba Cloud Lindorm and click Select.
-
On the Settings tab, configure the following parameters. Leave other parameters at their default values.
Setting
Parameter
Required
Description
Name
Yes
A custom name for the data source.
HTTP
URL
Yes
The HTTP endpoint of LindormTSDB. For more information, see View the connection information of LindormTSDB.
Important-
If your ECS instance is in the same VPC as the Lindorm instance, use the VPC endpoint of LindormTSDB. Otherwise, use the public address.
-
If you use the VPC endpoint, add the primary private IP address of the ECS instance to the Lindorm whitelist. If you use the public address, add the public IP address of the ECS instance to the Lindorm whitelist.
Auth
Basic auth
No
If user authentication is enabled for LindormTSDB, enable Basic auth and enter the username and password for LindormTSDB in the Basic Auth Details section. For more information about user authentication, see Manage users and permissions.
Basic auth details
User
No
The username for LindormTSDB. Required only if Basic auth is enabled.
Password
No
The password for LindormTSDB. Required only if Basic auth is enabled.
Lindorm TSDB details
Database
No
The LindormTSDB database that you want to access.
-
-
Click Save & test.
A "test success" message indicates that the connection is successful.
-
-
Create and use a dashboard in Grafana. For more information, see Create a dashboard.
-
On the Query tab, configure your query.
-
From the Data source list, select your data source.
-
Grafana provides two query editor modes: the template-based query editor and the SQL statement editor.
SQL statement editor
Click the
icon in the upper-right corner of section A to switch to the raw query editor. You can then enter Lindorm SQL statements to perform complex queries. For example:SELECT region,time,avg(temperature) FROM sensor WHERE time >= $from AND time <= $to SAMPLE BY $intervalNoteFor more information about Lindorm SQL syntax, see SELECT syntax.
-
The time condition
time >= $from AND time <= $tois mandatory; otherwise, the query will fail. The parameter values are automatically replaced with the time range selected on the dashboard. -
Under Query options, use the Min interval and Max data points settings to adjust the Interval.
-
Use ALIAS BY to rename a time series label. The format is
$tag_<tag_name>. For example, if you use$tag_host, the time series label displays the value of thehosttag. -
Use OFFSET to set a time offset, which helps you compare data from different time periods.
Template-based query editor
You can perform simple queries by using a template to select the table, fields, and query conditions. The following table describes the keywords.
Keyword
Description
SELECTSelect the field names to query.
FROMSelect the table name to query.
WHEREAdd query conditions.
GROUP BYAdd aggregation conditions.
SAMPLE BYSelect the time interval for downsampling. For more information, see Downsampling queries.
Click Query options to adjust the Interval parameter by using the Min interval and Max data points settings.
ORDER BY TIMESort the query results by time.
LIMITSpecify the number of rows to return in the result set.
ALIAS BYRename a time series label. The format is
$tag_<tag_name>. For example, if you use$tag_host, the time series label displays the value of thehosttag.OFFSETSet a time offset, which helps you compare data from different time periods.
-
-