Skip to main content

Telegraf

Telegraf is a very popular open-source metric collection software. In data collection and platform monitoring systems, Telegraf can collect operational information from various components without the need to manually write scripts for periodic collection, reducing the difficulty of data acquisition.

Simply add the output configuration of Telegraf to point to the corresponding URL of taosAdapter and modify several configuration items to write Telegraf's data into TDengine. Storing Telegraf's data in TDengine can fully utilize TDengine's efficient storage and query performance and cluster processing capabilities for time-series data.

Prerequisites

The following preparations are needed to write Telegraf data into TDengine:

  • TDengine cluster has been deployed and is running normally
  • taosAdapter has been installed and is running normally. For specific details, please refer to taosAdapter User Manual
  • Telegraf has been installed. To install Telegraf, please refer to the official documentation
  • Telegraf by default collects system operational status data. By enabling input plugins, data in other formats can be output to Telegraf and then written into TDengine.

Configuration Steps

In the Telegraf configuration file (default location /etc/telegraf/telegraf.conf), add the configuration for the outputs.http output module:

[[outputs.http]]
url = "http://<taosAdapter's host>:<REST service port>/influxdb/v1/write?db=<database name>"
...
username = "<TDengine's username>"
password = "<TDengine's password>"
...

Where <taosAdapter's host> should be filled with the domain name or IP address of the server running the taosAdapter service, <REST service port> should be filled with the port of the REST service (default is 6041), <TDengine's username> and <TDengine's password> should be filled with the actual configuration of the running TDengine, and <database name> should be filled with the database name where you want to save Telegraf data in TDengine.

Example as follows:

[[outputs.http]]
url = "http://127.0.0.1:6041/influxdb/v1/write?db=telegraf"
method = "POST"
timeout = "5s"
username = "root"
password = "taosdata"
data_format = "influx"

Verification Method

Restart the Telegraf service:

sudo systemctl restart telegraf

Use TDengine CLI to verify that data is being written from Telegraf to TDengine and can be correctly read:

taos> show databases;
name |
=================================
information_schema |
performance_schema |
telegraf |
Query OK, 3 rows in database (0.010568s)

taos> use telegraf;
Database changed.

taos> show stables;
name |
=================================
swap |
cpu |
system |
diskio |
kernel |
mem |
processes |
disk |
Query OK, 8 row(s) in set (0.000521s)

taos> select * from telegraf.system limit 10;
ts | load1 | load5 | load15 | n_cpus | n_users | uptime | uptime_format | host
|
=============================================================================================================================================================================================================================================
2022-04-20 08:47:50.000000000 | 0.000000000 | 0.050000000 | 0.070000000 | 4 | 1 | 5533 | 1:32 | shuduo-1804
|
2022-04-20 08:48:00.000000000 | 0.000000000 | 0.050000000 | 0.070000000 | 4 | 1 | 5543 | 1:32 | shuduo-1804
|
2022-04-20 08:48:10.000000000 | 0.000000000 | 0.040000000 | 0.070000000 | 4 | 1 | 5553 | 1:32 | shuduo-1804
|
Query OK, 3 row(s) in set (0.013269s)
note
  • The default subtable name generated by TDengine when receiving influxdb format data is a unique ID value generated according to rules. If users need to specify the generated table name, they can specify it by configuring the smlChildTableName parameter in taos.cfg. By controlling the input data format, you can use this feature of TDengine to specify the generated table name. For example: Configure smlChildTableName=tname and insert data as st,tname=cpu1,t1=4 c1=3 1626006833639000000, then the created table name is cpu1. If multiple rows of data have the same tname, but the tag_set behind them is different, the tag_set specified during the automatic table creation of the first row is used, and the other rows will be ignored. TDengine Schemaless Writing Reference Guide