diff --git a/docs/en/08-third-party/03-telegraf.md b/docs/en/08-third-party/03-telegraf.md index dd59972fefb0ae714a056757e27d41a59278d451..ff999272116e8356ff4aa560acdeba83a77bcf1e 100644 --- a/docs/en/08-third-party/03-telegraf.md +++ b/docs/en/08-third-party/03-telegraf.md @@ -3,78 +3,83 @@ sidebar_label: Telegraf title: Telegraf for TDengine Cloud --- -Telegraf is a viral, 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 is a 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. ## Install Telegraf -Please refer to the [official documentation](https://docs.influxdata.com/telegraf/v1.22/install/) for Telegraf installation. +Supposed that you use Ubuntu system: -## Configuration steps +```bash +{{#include docs/examples/thirdparty/install-telegraf.sh:null:nrc}} +``` + +After installation, telegraf service should have been started. Lets stop it: + +```bash +sudo systemctl stop telegraf +``` -In the Telegraf configuration file (default location `/etc/telegraf/telegraf.conf`) add an `outputs.http` section. +For installation instructions on other platforms please refer to the [official documentation](https://docs.influxdata.com/telegraf/v1.23/install/). +## Configuration -```conf -[[outputs.http]] - url = "/influxdb/v1/write?db=telegraf&token=" - method = "POST" - timeout = "5s" - data_format = "influx" - influx_max_line_bytes = 250 + +Run this command in your terminal to save TDengine cloud token and URL as variables: + +```bash +export TDENGINE_CLOUD_TOKEN="" +export TDENGINE_CLOUD_URL="" ``` +Run this command to generate new telegraf.conf. + +```bash +{{#include docs/examples/thirdparty/gen-telegraf-conf.sh:null:nrc}} +``` + +Edit section "outputs.http". + +```toml +{{#include docs/examples/thirdparty/telegraf-conf.toml:null:nrc}} +``` + +The resulting configuration will collect CPU and memory data and sends it to TDengine database named "telegraf". Database "telegraf" will be created automatically if it dose not exist in advance. + + You are expected to replace `` and `` with real TDengine cloud URL and token. To obtain the real values, please log in [TDengine Cloud](https://cloud.tdengine.com). -In above configuration example, all data will be written to database `telegraf`, but you can change it to any database you prefer. The database will be created automatically if it dose not exist in advance. - -## Verification plugin +## Start Telegraf -Restart Telegraf service: +Start telegraf using new generated telegraf.conf file. -``` -sudo systemctl restart telegraf +```bash +telegraf --config telegraf.conf ``` -Use TDengine CLI to verify Telegraf correctly writing data to TDengine and read out: +## Verification +Log in TDengine Cloud, click "Explorer" on the left navigation bar. + +Check weather database "telegraf" exist by executing: + +```sql +show databases; ``` -taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - telegraf | 2022-04-20 08:47:53.488 | 22 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 9 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.002401s) - -taos> use telegraf; -Database changed. - -taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - swap | 2022-04-20 08:47:53.532 | 7 | 1 | 1 | - cpu | 2022-04-20 08:48:03.488 | 11 | 2 | 5 | - system | 2022-04-20 08:47:53.512 | 8 | 1 | 1 | - diskio | 2022-04-20 08:47:53.550 | 12 | 2 | 15 | - kernel | 2022-04-20 08:47:53.503 | 6 | 1 | 1 | - mem | 2022-04-20 08:47:53.521 | 35 | 1 | 1 | - processes | 2022-04-20 08:47:53.555 | 12 | 1 | 1 | - disk | 2022-04-20 08:47:53.541 | 8 | 5 | 2 | -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) +![TDengine show telegraf databases](./telegraf-show-databases.webp) + +Check weather super table cpu and mem exist: + +```sql +show telegraf.stables; ``` + +![TDengine Cloud show telegraf stables](./telegraf-show-stables.webp) + + + + diff --git a/docs/en/08-third-party/telegraf-show-databases.webp b/docs/en/08-third-party/telegraf-show-databases.webp new file mode 100644 index 0000000000000000000000000000000000000000..8970f074eee3980d313de100218cbfaff84fbef0 Binary files /dev/null and b/docs/en/08-third-party/telegraf-show-databases.webp differ diff --git a/docs/en/08-third-party/telegraf-show-stables.webp b/docs/en/08-third-party/telegraf-show-stables.webp new file mode 100644 index 0000000000000000000000000000000000000000..7f93f0cb8d1d8d10c0cc5fcf0c0a895df8f0edb9 Binary files /dev/null and b/docs/en/08-third-party/telegraf-show-stables.webp differ diff --git a/docs/examples/thirdparty/gen-telegraf-conf.sh b/docs/examples/thirdparty/gen-telegraf-conf.sh new file mode 100644 index 0000000000000000000000000000000000000000..eb9987a8b76851b9f9b41a06f94934b5cead9046 --- /dev/null +++ b/docs/examples/thirdparty/gen-telegraf-conf.sh @@ -0,0 +1 @@ +telegraf --sample-config --input-filter cpu:mem --output-filter http > telegraf.conf \ No newline at end of file diff --git a/docs/examples/thirdparty/install-telegraf.sh b/docs/examples/thirdparty/install-telegraf.sh new file mode 100644 index 0000000000000000000000000000000000000000..c942194defd29fc4c29140334742e145e0b437b7 --- /dev/null +++ b/docs/examples/thirdparty/install-telegraf.sh @@ -0,0 +1,4 @@ +wget -q https://repos.influxdata.com/influxdb.key +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] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list +sudo apt-get update && sudo apt-get install telegraf \ No newline at end of file diff --git a/docs/examples/thirdparty/telegraf-conf.toml b/docs/examples/thirdparty/telegraf-conf.toml new file mode 100644 index 0000000000000000000000000000000000000000..002ff0cea5b25393df711b1ea3705bcb1e210f23 --- /dev/null +++ b/docs/examples/thirdparty/telegraf-conf.toml @@ -0,0 +1,6 @@ +[[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 \ No newline at end of file