taosKeeper 参考手册
taosKeeper 是 TDengine 3.0 版本监控指标的导出工具,通过简单的几项配置即可获取 TDengine 的运行状态。taosKeeper 使用 TDengine RESTful 接口,所以不需要安装 TDengine 客户端即可使用。
安装
taosKeeper 有两种安装方式:
-
安装 TDengine 官方安装包的同时会自动安装 taosKeeper, 详情请参考TDengine 安装。
-
单独编译 taosKeeper 并安装,详情请参考 taosKeeper 仓库。
配置
taosKeeper 需要在操作系统终端执行,该工具支持三种配置方式:命令行参数、环境变量 和 配置文件。优先级为:命令行参数、环境变量、配置文件参数。 一般我们推荐使用配置文件。
命令行参数和环境变量
命令行参数 和 环境变量说明可以参考命令 taoskeeper --help
的输出。下面是一个例子:
Usage of taoskeeper v3.3.3.0:
-R, --RotationInterval string interval for refresh metrics, such as "300ms", Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". Env "TAOS_KEEPER_ROTATION_INTERVAL" (default "15s")
-c, --config string config path default /etc/taos/taoskeeper.toml
--drop string run taoskeeper in command mode, only support old_taosd_metric_stables.
--environment.incgroup whether running in cgroup. Env "TAOS_KEEPER_ENVIRONMENT_INCGROUP"
--fromTime string parameter of transfer, example: 2020-01-01T00:00:00+08:00 (default "2020-01-01T00:00:00+08:00")
--gopoolsize int coroutine size. Env "TAOS_KEEPER_POOL_SIZE" (default 50000)
-h, --help Print this help message and exit
--instanceId int instance ID. Env "TAOS_KEEPER_INSTANCE_ID" (default 64)
--log.compress whether to compress old log. Env "TAOS_KEEPER_LOG_COMPRESS"
--log.keepDays uint log retention days, must be a positive integer. Env "TAOS_KEEPER_LOG_KEEP_DAYS" (default 30)
--log.level string log level (trace debug info warning error). Env "TAOS_KEEPER_LOG_LEVEL" (default "info")
--log.path string log path. Env "TAOS_KEEPER_LOG_PATH" (default "/var/log/taos")
--log.reservedDiskSize string reserved disk size for log dir (KB MB GB), must be a positive integer. Env "TAOS_KEEPER_LOG_RESERVED_DISK_SIZE" (default "1GB")
--log.rotationCount uint log rotation count. Env "TAOS_KEEPER_LOG_ROTATION_COUNT" (default 5)
--log.rotationSize string log rotation size(KB MB GB), must be a positive integer. Env "TAOS_KEEPER_LOG_ROTATION_SIZE" (default "1GB")
--log.rotationTime duration deprecated: log rotation time always 24 hours. Env "TAOS_KEEPER_LOG_ROTATION_TIME" (default 24h0m0s)
--logLevel string log level (trace debug info warning error). Env "TAOS_KEEPER_LOG_LEVEL" (default "info")
--metrics.database.name string database for storing metrics data. Env "TAOS_KEEPER_METRICS_DATABASE" (default "log")
--metrics.database.options.buffer int database option buffer for audit database. Env "TAOS_KEEPER_METRICS_BUFFER" (default 64)
--metrics.database.options.cachemodel string database option cachemodel for audit database. Env "TAOS_KEEPER_METRICS_CACHEMODEL" (default "both")
--metrics.database.options.keep int database option buffer for audit database. Env "TAOS_KEEPER_METRICS_KEEP" (default 90)
--metrics.database.options.vgroups int database option vgroups for audit database. Env "TAOS_KEEPER_METRICS_VGROUPS" (default 1)
--metrics.prefix string prefix in metrics names. Env "TAOS_KEEPER_METRICS_PREFIX"
--metrics.tables stringArray export some tables that are not super table, multiple values split with white space. Env "TAOS_KEEPER_METRICS_TABLES"
-P, --port int http port. Env "TAOS_KEEPER_PORT" (default 6043)
--tdengine.host string TDengine server's ip. Env "TAOS_KEEPER_TDENGINE_HOST" (default "127.0.0.1")
--tdengine.password string TDengine server's password. Env "TAOS_KEEPER_TDENGINE_PASSWORD" (default "taosdata")
--tdengine.port int TDengine REST server(taosAdapter)'s port. Env "TAOS_KEEPER_TDENGINE_PORT" (default 6041)
--tdengine.username string TDengine server's username. Env "TAOS_KEEPER_TDENGINE_USERNAME" (default "root")
--tdengine.usessl TDengine server use ssl or not. Env "TAOS_KEEPER_TDENGINE_USESSL"
--transfer string run taoskeeper in command mode, only support old_taosd_metric. transfer old metrics data to new tables and exit
-V, --version Print the version and exit
配置文件
taosKeeper 支持用 taoskeeper -c <keeper config file>
命令来指定配置文件。
若不指定配置文件,taosKeeper 会使用默认配置文件,其路径为: /etc/taos/taoskeeper.toml
。
若既不指定 taosKeeper 配置文件,且 /etc/taos/taoskeeper.toml
也不存在,将使用默认配置。
下面是配置文件的示例:
# The ID of the currently running taoskeeper instance, default is 64.
instanceId = 64
# Listening port, default is 6043.
port = 6043
# Go pool size
gopoolsize = 50000
# Interval for metrics
RotationInterval = "15s"
[tdengine]
host = "127.0.0.1"
port = 6041
username = "root"
password = "taosdata"
usessl = false
[metrics]
# Metrics prefix in metrics names.
prefix = "taos"
# Export some tables that are not super table.
tables = []
# Database for storing metrics data.
[metrics.database]
name = "log"
# Database options for db storing metrics data.
[metrics.database.options]
vgroups = 1
buffer = 64
keep = 90
cachemodel = "both"
[environment]
# Whether running in cgroup.
incgroup = false
[log]
# The directory where log files are stored.
# path = "/var/log/taos"
level = "info"
# Number of log file rotations before deletion.
rotationCount = 30
# The number of days to retain log files.
keepDays = 30
# The maximum size of a log file before rotation.
rotationSize = "1GB"
# If set to true, log files will be compressed.
compress = false
# Minimum disk space to reserve. Log files will not be written if disk space falls below this limit.
reservedDiskSize = "1GB"
启动
在运行 taosKeeper 之前要确保 TDengine 集群与 taosAdapter 已经在正确运行。 并且 TDengine 已经开启监控服务,TDengine 配置文件 taos.cfg
中至少需要配置 monitor
和 monitorFqdn
。
monitor 1
monitorFqdn localhost # taoskeeper 服务的 FQDN
TDengine 监控配置相关,具体请参考:TDengine 监控配置。
- Linux
- macOS
安装后,请使用 systemctl
命令来启动 taoskeeper 的服务进程。
systemctl start taoskeeper
检查服务是否正常工作:
systemctl status taoskeeper
如果服务进程处于活动状态,则 status 指令会显示如下的相关信息:
Active: active (running)
如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息:
Active: inactive (dead)
如下 systemctl
命令可以帮助你管理 taoskeeper 服务:
-
启动服务进程:
systemctl start taoskeeper
-
停止服务进程:
systemctl stop taoskeeper
-
重启服务进程:
systemctl restart taoskeeper
-
查看服务状态:
systemctl status taoskeeper
systemctl
命令需要 root 权限来运行,如果您非 root 用户,请在命令前添加sudo
。- 如果系统中不支持
systemd
,也可以用手动运行/usr/local/taos/bin/taoskeeper
方式启动 taoskeeper 服务。 - 故障排查:如果服务异常请查看日志获取更多信息。日志文件默认放在
/var/log/taos
下。
安装后,可以运行 sudo launchctl start com.tdengine.taoskeeper
来启动 taoskeeper 服务进程。
如下 launchctl
命令用于管理 taoskeeper 服务:
-
启动服务进程:
sudo launchctl start com.tdengine.taoskeeper
-
停止服务进程:
sudo launchctl stop com.tdengine.taoskeeper
-
查看服务状态:
sudo launchctl list | grep taoskeeper
launchctl
命令管理com.tdengine.taoskeeper
需要管理员权限,务必在前面加sudo
来增强安全性。sudo launchctl list | grep taoskeeper
指令返回的第一列是taoskeeper
程序的 PID,若为-
则说明 taoskeeper 服务未运行。- 故障排查:如果服务异常请查看日志获取更多信息。日志文件默认放在
/var/log/taos
下。
健康检查
可以访问 taosKeeper 的 check_health
接口来判断服务是否存活,如果服务正常则会返回 HTTP 200 状态码:
curl -i http://127.0.0.1:6043/check_health
返回结果:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Wed, 07 Aug 2024 06:19:50 GMT
Content-Length: 21
{"version":"3.3.2.3"}