Skip to main content

Telegraf for TDengine Cloud

Telegraf is an open-source, metrics collection software. Telegraf can collect the operation information of various components without having to write any scripts to collect regularly, reducing the difficulty of data acquisition.

Telegraf's data can be written to TDengine by simply adding the output configuration of Telegraf to the URL corresponding to taosAdapter and modifying several configuration items. The presence of Telegraf data in TDengine can take advantage of TDengine's efficient storage query performance and clustering capabilities for time-series data.


Before telegraf can write data into TDengine cloud service, you need to firstly manually create a database. Log in TDengine Cloud, click "Explorer" on the left navigation bar, then click the "+" button besides "Databases" to add a database named as "telegraf" using all default parameters.

Install Telegraf

Supposed that you use Ubuntu system:

wget -q
echo '23a1c8836f0afc5ed24e0486339d7cc8f6790b83886c4c96995b88a061c5bb5d influxdb.key' | sha256sum -c && cat influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf

After installation, telegraf service should have been started. Lets stop it:

sudo systemctl stop telegraf

For installation instructions on other platforms please refer to the official documentation.


Run this command in your terminal to save TDengine cloud token and URL as variables:

export TDENGINE_CLOUD_URL="<url>"
export TDENGINE_CLOUD_TOKEN="<token>"

You are expected to replace <url> and <token> with real TDengine cloud URL and token. To obtain the real values, please log in TDengine Cloud.

Then run this command to generate new telegraf.conf.

telegraf --sample-config --input-filter cpu:mem --output-filter http > telegraf.conf

Edit section "outputs.http".

url = "${TDENGINE_CLOUD_URL}/influxdb/v1/write?db=telegraf&token=${TDENGINE_CLOUD_TOKEN}"
method = "POST"
timeout = "5s"
data_format = "influx"
influx_max_line_bytes = 250

The resulting configuration will collect CPU and memory data and sends it to TDengine database named "telegraf". Database "telegraf" must be created first through TDengine Cloud explorer.

Start Telegraf

Start telegraf using new generated telegraf.conf file.

telegraf --config telegraf.conf


  • Check weather database "telegraf" exist by executing:
show databases;

TDengine show telegraf databases

Check weather super table cpu and mem exist:

show telegraf.stables;

TDengine Cloud show telegraf stables

  • Telegraf collects the running status measurements of current system. You can enable input plugins to insert other formats data to Telegraf then forward to TDengine.
  • TDengine take influxdb format data and create unique ID for table names by the rule. The user can configure smlChildTableName parameter to generate specified table names if he/she needs. And he/she also need to insert data with specified data format. For example, Add smlChildTableName=tname in the taos.cfg file. Insert data st,tname=cpu1,t1=4 c1=3 1626006833639000000 then the table name will be cpu1. If there are multiple lines has same tname but different tag_set, the first line's tag_set will be used to automatically creating table and ignore other lines. Please refer to TDengine Schemaless