All Products
Search
Document Center

Lindorm:Use Grafana to access LindormTSDB

Last Updated:Mar 01, 2024

Grafana is an open source visualization tool that can visualize large amounts of metric data. Grafana is commonly used to analyze Internet applications and is also widely used in industrial monitoring, meteorological monitoring, home automation, procedure management, and other sectors. LindormTSDB provides the Alibaba Cloud Lindorm data source plug-in for you to add Lindorm to Grafana as a data source. This topic describes how to use Grafana to access LindormTSDB and analyze data in a visualized GUI.

Use Managed Service for Grafana to access LindormTSDB

Prerequisites

  • A Grafana workspace is created. For more information, see Manage a workspace.

  • If you want to access LindormTSDB by using the Internet, perform the following operations:

Procedure

In this topic, Grafana 10.0.x is used as an example to show you how to access LindormTSDB.

  1. Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management. Then, click the workspace that you want to use to connect to LindormTSDB.

  2. In the Basic Information section, Enter the username and password. The username is admin. The password is configured when the workspace is created.

  3. Add Lindorm to Grafana as a data source.

    1. Click the image.png icon in the upper-left corner and select Manage. Then, click the data source.

    2. On the Manage page, click the data source.

    3. On the data source configuration page, click Add data source.

    4. Enter Alibaba Cloud Lindorm in the search box of the Add data source page. Find and then click the data source.

    5. Configure the parameters described in the following table on the Settings tab. You can keep the default values for other parameters.

      Configuration item

      Parameter

      Required

      Description

      Name

      Yes

      The name of the data source. You can specify a custom name.

      HTTP

      URL

      Yes

      The endpoint of LindormTSDB. For more information, see View the endpoints of LindormTSDB.

      Important

      Use the Internet endpoint of LindormTSDB, and make sure that the Internet endpoint of the Grafana service is added to the whitelist of the Lindorm instance.

      Auth

      Basic auth

      No

      If the user authentication and permission verification feature is enabled for LindormTSDB, turn on Basic auth and enter the username and password used to log on to LindormTSDB in the Basic Auth Details section. For more information, see User and permission management.

      Basic Auth Details

      User

      No

      The username that is used to log on to the Lindorm instance. You must specify this parameter if you turn on Basic auth.

      Password

      No

      The password that is used to log on to the Lindorm instance. You must specify this parameter if you turn on Basic auth.

      Lindorm TSDB Details

      Database

      No

      The LindormTSDB database that you want to access.

    6. Click Save & test.

      If the "test success" message is returned, the connection test is successful.

  4. Click Build a dashboard.

  5. On the New Dashboard page, click Add a new panel.

  6. Select the Lindorm data source that is added in step 3.

  7. Query data on the Query tab.

    1. Select the data source that you want to use from the Data source drop-down list.

    2. To query data in Grafana, you can use the SQL statement editor or template-based query editor.

      SQL statement editor

      Click the 切换 icon in upper-right corner of the A section and switch the editor to Raw Query Mode. Then, you can enter Lindorm SQL statements to perform complex queries. The following statement provides an example on how to perform a complex query:

      SELECT region,time,avg(temperature) FROM sensor WHERE time >= $from AND time <= $to SAMPLE BY $interval
      Note

      For more information about how to use Lindorm SQL, see Basic syntax of SELECT statements.

      • time >= $from AND time <= $to specifies a time condition. This condition is required in the statement. If you do not specify it, the query result is not returned. The variables in the condition are automatically replaced with the time range selected on the dashboard page.

      • You can click Query options and specify the Min interval and Max data points parameters to adjust the value of Interval.

      • You can use ALIAS BY to rename the tags of time series. The alias of a time series is in the $tag_<tag_name> format. For example, you can set the tag of a time series to $tag_host. In this case, the tag of the time series is the host name.

      • You can use OFFSET to configure a time offset. This allows you to compare data that is generated within different time periods.

      Template-based query editor

      You can specify query conditions and the tables and fields that you want to query in a template to perform simple queries. The following table describes the keywords that you can specify in the editor.更新选择框

      Keyword

      Description

      SELECT

      Specify the names of the fields that you want to query.

      FROM

      Specify the name of the table that you want to query.

      WHERE

      Add query conditions.

      GROUP BY

      Add aggregate conditions.

      SAMPLE BY

      Specify the interval of downsampling. For more information, see Downsampling queries.

      You can click Query options and specify the Min interval and Max data points parameters to adjust the value of Interval.

      ORDER BY TIME

      Specify the sorting order.

      LIMIT

      Specify the maximum number of rows that can be returned in a result set.

      ALIAS BY

      Rename the tag of the time series. The alias of a time series is in the $tag_<tag_name> format. For example, you can set the tag of a time series to $tag_host. In this case, the tag of the time series is the host name.

      OFFSET

      Specify the time offset. This allows you to compare data that is generated within different time periods.

Use a self-managed Grafana service deployed on an ECS instance to access LindormTSDB

Deployment requirements

  • The operating system of the ECS instance is 64-bit CentOS 7.3 or later versions.

  • The ECS instance must have more than 1 CPU core, 2 GB of memory, and 10 GB of available storage capacity.

Prerequisites

  • A rule that allows traffic on port 3000 is added to the security group of the ECS instance. For more information, see Add a security group rule.

  • The IP address of the ECS instance is added to the whitelist of the Lindorm instance.

    The ECS instance and the Lindorm instance are in the same VPC: Add the private IP address of the ECS instance to the whitelist of the Lindorm instance. For more information, see Configure whitelists.

    The ECS instance and the Lindorm instance are in different VPCs:

    • Allocate a public IP address for the ECS instance. If no public IP address is allocated for the ECS instance, associate an EIP with the ECS instance or modify the bandwidth configurations of the instance. For more information, see Associate an EIP with an ECS instance and Modify bandwidth configurations.

    • Add the public IP address of the ECS instance to the whitelist of the Lindorm instance. For more information, see Configure whitelists.

  • If you access the web UI of Grafana over the Internet, make sure that a public IP address is allocated for the ECS instance. If no public IP address is allocated for the ECS instance, associate an EIP with the ECS instance or modify the bandwidth configurations of the instance. For more information, see Associate an EIP with an ECS instance and Modify bandwidth configurations. If you access the web UI of Grafana over the VPC, you do not need to allocate a public IP address for the ECS instance.

Procedure

  1. Install Grafana. If Grafana is installed, skip this step.

    1. Log on to the ECS instance. For more information, see Connect to an 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 choose the version of Grafana that you want to install based on your requirements. For more information about how to download other versions of Grafana, visit the Grafana official website.

    3. Run the following command to install Grafana:

      sudo yum install grafana-enterprise-8.2.2-1.x86_64.rpm
    4. 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 Alibaba Cloud Lindorm data source plug-in:

      wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/grafana-alibabacloud-lindorm-datasource-latest.zip
    2. Run the following command to extract the package to the default directory. The default directory in Linux is /var/lib/grafana/plugins/.

      unzip grafana-alibabacloud-lindorm-datasource-latest.zip -d /var/lib/grafana/plugins/
    3. Run the following command to modify the grafana.ini file. By default, the path of the file in Linux is /etc/grafana/grafana.ini.

      sudo nano -w  /etc/grafana/grafana.ini
    4. In the [plugins] section, change ;allow_loading_unsigned_plugins= to allow_loading_unsigned_plugins = alibabacloud-lindorm-datasource. After you modify the parameter, press CTRL + O to save the change and press Enter to exit the edit mode.

      Important

      When you modify the grafana.ini file, you must delete the semicolon (;) in ;allow_loading_unsigned_plugins.

    5. Run the following command to restart Grafana:

      sudo service grafana-server restart
  3. Add Lindorm to Grafana as a data source.

    1. Enter the following URL in the address bar of your browser: http://IP:3000/. Replace the "IP" field in the URL with the public IP address or primary private IP address of your ECS instance. Enter the username and password. If you log on to the self-managed Grafana service for the first time, both the username and password are admin. Change the password after you log on to the Grafana service. For more information, see Sign in to Grafana.

    2. Click the 设置 icon on the left and select Data Sources from the drop-down list.

    3. On the Configuration page, click Add data source.

    4. On the Add data source page, enter Alibaba Cloud Lindorm in the search box, find the data source that you want to add, and then click Select.

    5. Configure the parameters described in the following table on the Settings tab. You can keep the default values for other parameters.

      Configuration item

      Parameter

      Required

      Description

      Name

      Yes

      The name of the data source. You can specify a custom name.

      HTTP

      URL

      Yes

      The endpoint of LindormTSDB. For more information, see View the endpoints of LindormTSDB.

      Important
      • If the ECS instance belongs to the same VPC as the Lindorm instance, use the VPC endpoint of LindormTSDB. Otherwise, use the Internet endpoint of LindormTSDB.

      • If you specify the VPC endpoint of LindormTSDB, make sure that the primary private IP address of the ECS instance is added to the whitelist of the Lindorm instance. If you specify the Internet endpoint of LindormTSDB, make sure that the public IP address of the ECS instance is added to the whitelist of the Lindorm instance.

      Auth

      Basic auth

      No

      If the user authentication and permission verification feature is enabled for LindormTSDB, turn on Basic auth and enter the username and password used to log on to LindormTSDB in the Basic Auth Details section. For more information, see User and permission management.

      Basic Auth Details

      User

      No

      The username that is used to log on to the Lindorm instance. You must specify this parameter if you turn on Basic auth.

      Password

      No

      The password that is used to log on to the Lindorm instance. You must specify this parameter if you turn on Basic auth.

      Lindorm TSDB Details

      Database

      No

      The LindormTSDB database that you want to access.

    6. Click Save & test.

      If the "test success" message is returned, the connection test is successful.

  4. After you connect the self-managed Grafana service to the Lindorm instance, you can create and use dashboards in the Grafana service. For more information, see Create a dashboard.

  5. Query data on the Query tab.

    1. Select the data source that you want to use from the Data source drop-down list.

    2. To query data in Grafana, you can use the SQL statement editor or template-based query editor.

      SQL statement editor

      Click the 切换 icon in upper-right corner of the A section and switch the editor to Raw Query Mode. Then, you can enter Lindorm SQL statements to perform complex queries. The following statement provides an example on how to perform a complex query:

      SELECT region,time,avg(temperature) FROM sensor WHERE time >= $from AND time <= $to SAMPLE BY $interval
      Note

      For more information about how to use Lindorm SQL, see Basic syntax of SELECT statements.

      • time >= $from AND time <= $to specifies a time condition. This condition is required in the statement. If you do not specify it, the query result is not returned. The variables in the condition are automatically replaced with the time range selected on the dashboard page.

      • You can click Query options and specify the Min interval and Max data points parameters to adjust the value of Interval.

      • You can use ALIAS BY to rename the tags of time series. The alias of a time series is in the $tag_<tag_name> format. For example, you can set the tag of a time series to $tag_host. In this case, the tag of the time series is the host name.

      • You can use OFFSET to configure a time offset. This allows you to compare data that is generated within different time periods.

      Template-based query editor

      You can specify query conditions and the tables and fields that you want to query in a template to perform simple queries. The following table describes the keywords that you can specify in the editor.更新选择框

      Keyword

      Description

      SELECT

      Specify the names of the fields that you want to query.

      FROM

      Specify the name of the table that you want to query.

      WHERE

      Add query conditions.

      GROUP BY

      Add aggregate conditions.

      SAMPLE BY

      Specify the interval of downsampling. For more information, see Downsampling queries.

      You can click Query options and specify the Min interval and Max data points parameters to adjust the value of Interval.

      ORDER BY TIME

      Specify the sorting order.

      LIMIT

      Specify the maximum number of rows that can be returned in a result set.

      ALIAS BY

      Rename the tag of the time series. The alias of a time series is in the $tag_<tag_name> format. For example, you can set the tag of a time series to $tag_host. In this case, the tag of the time series is the host name.

      OFFSET

      Specify the time offset. This allows you to compare data that is generated within different time periods.