All Products
Search
Document Center

Connect Grafana to TSDB for InfluxDB®️ Service

Last Updated: Oct 20, 2021

Grafana is an open source tool to visualize large amounts of time series data. It is widely used in scenarios such as industrial monitoring, meteorological monitoring, home automation, and process management, and the analysis of Internet architecture and applications. After you connect TSDB for InfluxDB® to Grafana, you can use the various easy-to-use visualization features provided by Grafana to monitor and analyze the data stored in TSDB for InfluxDB®. This topic describes how to connect TSDB for InfluxDB® to Grafana.

Prerequisites

The TSDB for InfluxDB® service is purchased. The user account and the database are created. In addition, a certain amount of data is written to the database. If the TSDB for InfluxDB® service is not purchased, purchase the service before proceeding. After you purchase the TSDB for InfluxDB® service, you must create a user account, a database, and a retention policy. You must also grant the user account the permissions to access the database. Then, you must write a certain amount of data to the database. This allows Grafana to use the written data to generate monitoring charts for data visualization.

Access practices

  1. Download and install Grafana.

    You can download Grafana from its official website https://grafana.com/grafana/download. The website provides the details about how to install Grafana on various operating systems. Download an installation package based on the version and the configuration of your operating system, and install the package.

    CentOS is used as an example. You can run the following commands to download and install the package:

    wget https://dl.grafana.com/oss/release/grafana-6.1.4-1.x86_64.rpm sudo yum localinstall grafana-6.1.4-1.x86_64.rpm
  2. Start and log on to the Grafana service.

    Run a command to start the Grafana service based on your operating system.

    CentOS:

    service grafana-server start

    macOS:

    brew services start grafana

    After you start Grafana, open your browser, and enter the IP address and the port number of Grafana in the address bar of the browser. Note that port 3000 is the default listening port of Grafana. If you use on-premises Grafana services, enter 127.0.0.1:3000 in the address bar of your browser. If you use Grafana services that are hosted by Elastic Compute Service (ECS) instances, log on to the Alibaba Cloud ECS console and find the public IP address of the ECS instances.

    The default administrator account and password of Grafana are admin. You can change the default password when you log on to Grafana for the first time.

  3. The data source configuration.

    On the Grafana homepage, click Add data source.

    On the page that appears, configure the basic settings of TSDB for InfluxDB®, such as network connection, database details, and permissions. (1) Type: Select InfluxDB. (2) HTTP URL: Enter the public endpoint of the TSDB instance. To view the public endpoint, log on to the Alibaba Cloud TSDB for InfluxDB® console. In the left-side navigation pane, click Instances. On the page that appears, find the target instance, and click Manage in the Actions column. On the Instance Details page, you can view the public endpoint. (3) InfluxDB Details: Specify the target TSDB for InfluxDB® database, the user account of the database, and the password of the user account.

  4. The dashboard configuration.

    New dashboard

    A dashboard is a key component of Grafana for data visualization. Based on the configured query rules, Grafana retrieves data from TSDB for InfluxDB® and shows the data by using dashboards. This topic uses graphs as an example to configure a dashboard.

    (1) On the homepage of Grafana, choose Create > Dashboard.

    (2) On the Add tab, click Graph.

    Edit query rules

    Click the drop-down arrow of the panel title, and select Edit from the drop-down list.

    On the page that appears, you can edit query rules.

    The steps of configuring query rules are described as follows: (1) Data Source: Set Data Source to a data source that you have configured. (2) FROM: Specify the retention policy and the measurement. To do this, set the first two values that are displayed on the right side of the FROM parameter. (3) WHERE: Specify one or more tag filters. (4) SELECT: Specify the filters for fields and aggregate functions. If you have configured a GROUP BY condition for the time.

    you must configure aggregate functions. The configured aggregate functions are run from left to right. The following figure shows an example. In this example, the following SELECT statement is executed in TSDB for InfluxDB®:

    SELECT derivative(mean("field10"),10s)/10 AS "REQ/s" FROM ....

    (5) GROUP BY: Specify the conditions based which GROUP BY operations are performed, such as time, tags, sorting order, and limits. 1

    (6) FORMAT AS: Specify how to show data. (7) ALIAS BY: Specify an alias of a measurement or a tag. (8) Click Add Query to configure one or more subqueries. (9) In the upper-right corner of the page, click the Save icon.

    1

    Graphs that show query results

    The graphs instantly show data based on the query rules that you have configured. The following figures show the examples of graphs.

    1