Grafana is an open source visualization tool that can display large amounts of metric data. Grafana is widely used in Internet application analysis, industrial monitoring, meteorological monitoring, home automation, process management, and other fields. After you connect an ApsaraDB for Lindorm (Lindorm) TSDB instance to Grafana, you can use the visualization features provided by Grafana to monitor and analyze the data collected from the instance.
This topic describes how to connect a Lindorm TSDB instance to Grafana.
Prepare the environment
This topic describes how to install Grafana on an Elastic Compute Service (ECS) instance and connect Grafana to a Lindorm TSDB instance by using a virtual private cloud (VPC).
Create a Lindorm TSDB instance. Create an ECS instance. Connect the Lindorm TSDB instance and the ECS instance to the same VPC. Make sure that the following requirements are met:
- The OS of the ECS instance is 64-bit CentOS 7.3.
- The ECS instance has at least one CPU core and 2 GB memory. The available disk storage is no less than 10 GB.
- The private IP address of the ECS instance in the VPC is added to the whitelist of the Lindorm TSDB instance.
- If you want to use a browser to access Grafana over the Internet, configure a public IP address for the ECS instance.
- You have created a security group rule in the ECS console to enable access to the ECS instance over port 3000. The security group rule is shown in the following figure.
Install and configure Grafana
Perform the following steps to install and start Grafana on the ECS instance:
- Run the following command on the ECS instance to install Grafana:
$ sudo yum install https://dl.grafana.com/oss/release/grafana-6.2.2-1.x86_64.rpmNote For more information, see Grafana official documentation.
- Run the following command to start the Grafana service:
$ sudo service grafana-server start
Connect the Lindorm TSDB instance to Grafana
- Connect to the ECS instance over port 3000 by using a browser. The Grafana logon page appears. For example, if the public IP address of the ECS instance is 126.96.36.199, enter http://188.8.131.52:3000/ in the address bar of your browser.
- On the Grafana logon page, enter the username admin and the password admin. The Grafana homepage appears.
- Create a data source in Grafana. You can use the default values of some parameters.
However, you must specify the following parameters:
- Set the database type to OpenTSDB.
- URL: Enter the private IP address of the time series engine in the VPC. To view this address, go to the Instance list page in the Lindorm console, and check the value in the VPC Network Address field in the Basic Information section.
- Version: Select ==2.3.
- If you activate the user management feature for the Lindorm TSDB instance, you must select Basic Auth and With Credentials and enter the authentication information of a user that has the read permissions.
Click Save & Test. If the
Data source is working message appears on the page, the Lindorm TSDB instance is connected to Grafana.
After you perform the preceding operations, you can create and use dashboards in Grafana. For more information, see Grafana official documentation.
- Specify the metric that you need to monitor and whether to aggregate the metric values in different time series.
- Configure the parameters of the downsampling policy, including interval, Aggregator, and Fill.
- Specify the tags that are used to define the time series to be monitored. If you need to monitor the time series that correspond to all the tag values of a tag, enter an asterisk (*) in the Tags field. Note: Grafana supports multiple aggregators. For information about the aggregators that are supported by Lindorm TSDB, see Query single-value data points.
You can specify the time series that you need to display by specifying the metric, tag key, and tag value when you add a query in the dashboard, as described in the preceding section. However, if multiple time series exist and the number of time series is increasing at a high rate, you must specify Metric and Tags for each new time series to display the time series in an existing panel. This may increase your workload. To simplify the procedure, Grafana allows you to use variables.
This section describes how to use variables to filter the time series to be displayed. In the example, a variable is created and used to filter tags.
- Set Data source to OpenTSDB.
- In the Query field, enter a query expression that is supported by Grafana to query data in OpenTSDB. In this example, the variable to be created represents the tag value. Therefore, an expression that starts with tag_values is used.
- Lindorm TSDB supports all the template query variables that Grafana provides for OpenTSDB:
- metrics(prefix): returns all the metrics that have the specified prefix. This expression may return an empty array.
- tag_names(metric): returns all the tag keys that correspond to the specified metric.
- tag_values(metric, tagKey): returns all the tag values that correspond to the specified metric and the specified tag key.
- suggest_tagk(prefix): returns all the tag keys that have the specified prefix.
- suggest_tagv(prefix): returns all the tag values that have the specified prefix.