Skip to main content

Grafana

TDengine can be quickly integrated with the open-source data visualization system Grafana to build a data monitoring and alerting system. The whole process does not require any code development. And you can visualize the contents of the data tables in TDengine on a dashboard. You can learn more about using the TDengine plugin on GitHub.

Prerequisites

In order for Grafana to add the TDengine data source successfully, the following preparations are required:

  1. The TDengine cluster is deployed and functioning properly
  2. taosAdapter is installed and running properly. Please refer to the taosAdapter manual for details.

Record these values:

  • TDengine REST API url: http://tdengine.local:6041.
  • TDengine cluster authorization, with user + password.

Installing Grafana

TDengine currently supports Grafana versions 7.5 and above. Users can go to the Grafana official website to download the installation package and execute the installation according to the current operating system. The download address is as follows: https://grafana.com/grafana/download.

Configuring Grafana

Install Grafana Plugin and Configure Data Source

On a server with Grafana installed, run install.sh with TDengine url and username/passwords will install TDengine data source plugin and add a data source named TDengine. This is the recommended way for Grafana 7.x or Grafana provisioning users.

bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/taosdata/grafanaplugin/master/install.sh)" -- \
-a http://localhost:6041 \
-u root \
-p taosdata

Restart Grafana service and open Grafana in web-browser, usually http://localhost:3000.

Save the script and type ./install.sh --help for the full usage of the script.

Create Dashboard

Go back to the main interface to create a dashboard and click Add Query to enter the panel query page:

TDengine Database TDinsight plugin create dashboard 1

As shown above, select the TDengine data source in the Query and enter the corresponding SQL in the query box below for query.

  • INPUT SQL: Enter the desired query (the results being two columns and multiple rows), such as select _wstart, avg(mem_free) from log.taosd_dnodes_info where _ts >= $from and _ts < $to interval($interval). In this statement, $from, $to, and $interval are variables that Grafana replaces with the query time range and interval. In addition to the built-in variables, custom template variables are also supported.
  • ALIAS BY: This allows you to set the current query alias.
  • GENERATE SQL: Clicking this button will automatically replace the corresponding variables and generate the final executed statement.
  • Group by column name(s): group by or partition by columns name split by comma. By setting Group by column name(s), it can show multi-dimension data if Sql is group by or partition by. Such as, it can show data by dnode_ep if sql is select _wstart as ts, avg(mem_free), dnode_ep from log.taosd_dnodes_info where _ts>=$from and _ts<=$to partition by dnode_ep interval($interval) and Group by column name(s) is dnode_ep.
  • Format to: format legend for group by or partition by. Such as it can display series data by dnode_ep if sql is select _wstart as ts, avg(mem_free), dnode_ep from log.taosd_dnodes_info where _ts>=$from and _ts<=$to partition by dnode_ep interval($interval) and Group by column name(s) is dnode_ep and Format to is mem_free_{{dnode_ep}}.
note

Since the REST connection because is stateless. Grafana plugin can use <db_name>.<table_name> in the SQL command to specify the database name.

Follow the default prompt to query the average system free memory for the specified interval on the server where the current TDengine deployment is located as follows.

TDengine Database TDinsight plugin create dashboard 2

The example to query the average system free memory for the specified interval on each server as follows.

TDengine Database TDinsight plugin create dashboard 2

For more information on how to use Grafana to create the appropriate monitoring interface and for more details on using Grafana, refer to the official Grafana documentation.

Importing the Dashboard

You can install TDinsight dashboard in data source configuration page (like http://localhost:3000/datasources/edit/1/dashboards) as a monitoring visualization tool for TDengine cluster. Ensure that you use TDinsight for 3.x. Please note TDinsight for 3.x needs to configure and run taoskeeper correctly.

TDengine Database Grafana plugine import dashboard

A dashboard for TDengine 2.x has been published on Grafana: Dashboard 15167 - TDinsight).

For more dashboards using TDengine data source, search here in Grafana. Here is a sub list:

  • 15146: Monitor multiple TDengine clusters.
  • 15155: TDengine alert demo.
  • 15167: TDinsight.
  • 16388: Telegraf node metrics dashboard using TDengine data source.