TDengine/docs/zh/14-reference/01-components/_statsd.mdx
Xuefeng Tan 6f02ab7e4a
docs: add smlAutoCreateDB configuration for taosAdapter (#33343)
* docs: add smlAutoCreateDB configuration for taosAdapter in multiple documentation files

* docs: add description for smlAutoCreateDB configuration
2025-10-24 09:23:19 +08:00

58 lines
2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#### 配置 taosAdapter
配置 taosAdapter 接收 StatsD 数据的方法:
- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml中使能配置项
```toml
# 写入 Schemaless 数据时自动创建数据库
smlAutoCreateDB = true
[statsd]
enable = true
port = 6044
db = "statsd"
user = "root"
password = "taosdata"
worker = 10
gatherInterval = "5s"
protocol = "udp"
maxTCPConnections = 250
tcpKeepAlive = false
allowPendingMessages = 50000
deleteCounters = true
deleteGauges = true
deleteSets = true
deleteTimings = true
```
其中 taosAdapter 默认写入的数据库名称为 `statsd`,也可以修改 taosAdapter 配置文件 db 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。
`smlAutoCreateDB` 配置项用于使能自动创建数据库功能,设置为 true 时taosAdapter 会在接收到数据时自动创建对应的数据库(如果不存在)。
- 使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 StatsD 数据功能,具体细节请参考 taosAdapter 的参考手册
#### 配置 StatsD
使用 StatsD 需要下载其[源代码](https://github.com/statsd/statsd)。其配置文件请参考其源代码下载到本地的根目录下的示例文件 `exampleConfig.js` 进行修改。其中 \<taosAdapter's host> 填写运行 taosAdapter 的服务器域名或 IP 地址,\<port for StatsD> 请填写 taosAdapter 接收 StatsD 数据的端口(默认为 6044
```
backends 部分添加 "./backends/repeater"
repeater 部分添加 { host:'<taosAdapter's host>', port: <port for StatsD>}
```
示例配置文件:
```js
{
port: 8125
, backends: ["./backends/repeater"]
, repeater: [{ host: '127.0.0.1', port: 6044}]
}
```
增加如下内容后启动 StatsD假设配置文件修改为 config.js
```shell
npm install
node stats.js config.js &
```