未验证 提交 f1080648 编写于 作者: B Bo Ding 提交者: GitHub

Merge pull request #14943 from taosdata/docs/TD-17422

docs: telegraf.md
...@@ -3,78 +3,83 @@ sidebar_label: Telegraf ...@@ -3,78 +3,83 @@ sidebar_label: Telegraf
title: Telegraf for TDengine Cloud 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. 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 ## 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]] Run this command in your terminal to save TDengine cloud token and URL as variables:
url = "<url>/influxdb/v1/write?db=telegraf&token=<token>"
method = "POST" ```bash
timeout = "5s" export TDENGINE_CLOUD_TOKEN="<token>"
data_format = "influx" export TDENGINE_CLOUD_URL="<url>"
influx_max_line_bytes = 250
``` ```
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.
<!-- exclude --> <!-- exclude -->
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](https://cloud.tdengine.com). 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](https://cloud.tdengine.com).
<!-- exclude-end --> <!-- exclude-end -->
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.
``` ```bash
sudo systemctl restart telegraf 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; ![TDengine show telegraf databases](./telegraf-show-databases.webp)
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
==================================================================================================================================================================================================================================================================================== Check weather super table cpu and mem exist:
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 | ```sql
Query OK, 2 row(s) in set (0.002401s) show telegraf.stables;
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 Cloud show telegraf stables](./telegraf-show-stables.webp)
telegraf --sample-config --input-filter cpu:mem --output-filter http > telegraf.conf
\ No newline at end of file
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
[[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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册