You can use the Alibaba Cloud Lindorm plug-in of Grafana to access ApsaraDB for Lindorm instances. This topic describes how to connect Grafana that is deployed on an Elastic Compute Service (ECS) instance to a Lindorm instance and analyze data in a visualized manner.

Background information

Grafana is an open source visualization tool that can show large amounts of metric data. Grafana is widely used in Internet application analysis, industrial monitoring, meteorological monitoring, home automation, process management, and other fields.

Prerequisites

  • Make sure that the ECS instance and the Lindorm instance reside in the same virtual private cloud (VPC).
  • Make sure that the ECS instance can be accessed over the Internet. If no public IP address is specified, you can apply for an elastic IP address (EIP). For more information, see Apply for an EIP address.
  • Add the internal IP address of the ECS instance to the whitelist of the Lindorm instance. For more information, see Configure a whitelist.
  • A rule that allows traffic on port 3000 is added to the security group for the ECS instance. For more information, see Add security group rules.

Requirements for the ECS instance

  • The operating system must be 64-bit CentOS 7.3 or later.
  • The following minimum configuration of the hardware resources is required: a single-core CPU, 2 GB of memory, and 10 GB of available disk space.

Procedure

  1. Install Grafana. If Grafana is installed, skip this step.
    1. Log on to the ECS instance.
    2. Run the following command to download Grafana:
      wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.2.2-1.x86_64.rpm
      Note In this example, Grafana 8.2.2-1 is used. You can also install another version of Grafana. For more information, see the Grafana documentation.
    3. Run the following command to install Grafana:
      sudo yum install grafana-enterprise-8.2.2-1.x86_64.rpm
      Note To install Grafana, you can also follow the instructions provided in the documentation on the official Grafana website. For more information, see Install Grafana.
    4. Run the following command to modify the settings in the grafana.ini file:
      sudo nano -w  /etc/grafana/grafana.ini
    5. In the [plugins] section, change ;allow_loading_unsigned_plugins= to allow_loading_unsigned_plugins = alibabacloud-Lindorm-datasource. After you change the statement, press CTRL+O to save the setting. Then, press Enter to exit edit mode.
    6. Run the following command to start Grafana:
      sudo service grafana-server start
  2. Install the Alibaba Cloud Lindorm plug-in.
    1. Run the following command to download the plug-in:
      wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/grafana-alibabacloud-lindorm-datasource-1.0.1.zip
    2. Run the following command to decompress the plug-in to the default directory:
      unzip grafana-alibabacloud-lindorm-datasource-1.0.1.zip
    3. Move the grafana-alibabacloud-lindorm-datasource file to the /var/lib/grafana/plugins/ directory.
    4. Run the following command to restart Grafana:
      service grafana-server restart
  3. Add an Alibaba Cloud Lindorm data source.
    1. Log on to the Grafana console and go to the homepage. For more information, see Log on to the Grafana console.
    2. In the left-side navigation pane, choose Settings > Data Sources.
    3. On the Configuration page, click Add data source.
    4. In the Add data source section, enter Alibaba Cloud Lindorm in the search box, find the data source that you want to use, and then click Select.
    5. On the Settings tab, set the parameters. The following table describes the parameters. Configure parameters
      Parameter Description
      Name The name of the data source.
      Default The Default switch. By default, the switch is turned on.
      URL The endpoint of the Lindorm instance.
    6. Click Save & Test. If the Database Connection OK message appears, the connection between Grafana and the Lindorm instance is established.
    7. On the Query tab, enter the following SQL statement to analyze the data that is queried. The following figure shows the sample analysis result.
      SELECT region,time,temperature FROM sensor WHERE $timeFilter
      Enter an SQL statement
      Note
      • The $timeFilter variable in the SELECT statement specifies a time condition. The time condition is automatically replaced with the time range that you specify on the Query tab. The value of the $timeFilter variable is in the time>=<xxx> and time<=<xxx> format.
      • The SELECT statement must include the time field. Otherwise, the analysis result does not appear.
      • You can add a tag to the SELECT statement to aggregate data by group.