background

Currently we have used TDengine to store a large amount of data, which is generally required to be presented to users in various ways or passed on to upper-level businesses after statistics. As a timing database, ideal for storing structured log data, similar to InfluxDB, TDengine can easily integrate with Grafana without any code development, and the contents of TDengine’s data tables can be visually displayed on the dashboard. This time we will start with the TDengine self-recorded logs and the official tdEngine-grafana.json data screen.

Note: TDengine 2.1.2.0 service runs on CentOS7 virtual machine, Grafana 6.2.5 installed on Windows operating system (Win10).

Let’s take a look at the effect

Grafana plugin for TDengine

  • Add the plug-in

Put TDengine Grafana plugin/usr/local/taos copied to/connector/grafanaplugin directory D: \ Applications \ grafana – 6.2.5 \ data \ plugins \ tdengine directory

  • Start the Grafana

Double-click the D: \ Applications \ grafana – 6.2.5 \ bin \ grafana – server. Exe.

Configure to use the TDengine data source

Import the Dashboard

Json: D:\Applications\grafana-6.2.5\data\plugins\ tdEngine \dashboard\tdengine-grafana.json

SQL used to display TDengine logs in Grafana

-- req_select
select sum(req_select) from log.dn where ts > = now- 1h and ts < now interval(1m)

-- req_insert
select sum(req_insert) from log.dn where ts > = now- 1h and ts < now interval(1m)

-- mem_taosd
select  max(mem_taosd)  from log.dn where ts > = now - 10m and ts < now

-- mem_system
select  max(mem_system)  from log.dn where ts > = now - 10h and ts < now

-- band_speed
select avg(band_speed)  from log.dn where ts > = now- 1h and ts < now interval(1m)

-- cpu_system11
select  avg(cpu_system) from log.dn where ts > = now- 1h and ts < now  interval(1s)

-- cpu_taosd
select  avg(cpu_taosd) from log.dn where ts > = now- 1h and ts < now  interval(1s)

-- avg_disk_used
select avg(disk_used)  disk_used from log.dn where ts > = 'the 2021-07-29 T01:01:46. 744 z' and ts < 'the 2021-07-29 T02:01:46. 744 z' interval(1s) group by fqdn
Copy the code

Problems encountered

When importing Dashboard in the previous step, the browser reported an error:

Solution: Use the updated tdengine-grafana.json file to import a similar problem through the Issues of the source repository.

Github.com/taosdata/TD…

Github.com/taosdata/gr…

Reference

  • www.taosdata.com/cn/document…

If you have any questions or any bugs are found, please feel free to contact me.

Your comments and suggestions are welcome!

This article has participated in the activity of “New person creation Ceremony”, and started the road of digging gold creation together.