taosKeeper

简介

taosKeeper 是 TDengine 3.0 版本监控指标的导出工具,通过简单的几项配置即可获取 TDengine 的运行状态。taosKeeper 使用 TDengine RESTful 接口,所以不需要安装 TDengine 客户端即可使用。

安装

taosKeeper 安装方式:

  • 单独编译 taosKeeper 并安装,详情请参考 taosKeeper 仓库。

运行

配置和运行方式

taosKeeper 需要在操作系统终端执行,该工具支持三种配置方式:命令行参数、环境变量 和 配置文件。优先级为:命令行参数、环境变量、配置文件参数。

在运行 taosKeeper 之前要确保 TDengine 集群与 taosAdapter 已经在正确运行。 并且 TDengine 已经开启监控服务,TDengine 配置文件 taos.cfg 中至少需要配置 monitor 和 monitorFqdn。

1. monitor 1
2. monitorFqdn localhost # taoskeeper 服务的 FQDN

TDengine 监控配置相关,具体请参考:TDengine 监控配置。

命令行参数启动

在使用命令行参数运行 taosKeeper 并控制其行为。

1. $ taosKeeper

环境变量启动

通过设置环境变量达到控制启动参数的目的,通常在容器中运行时使用。

1. $ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3

3. $ taoskeeper

具体参数列表请参照 taoskeeper -h 输入结果。

配置文件启动

执行以下命令即可快速体验 taosKeeper。当不指定 taosKeeper 配置文件时,优先使用 /etc/taos/keeper.toml 配置,否则将使用默认配置。

1. $ taoskeeper -c <keeper config file>

下面是配置文件的示例:

1. # gin 框架是否启用 debug
2. debug = false

4. # 服务监听端口, 默认为 6043
5. port = 6043

7. # 日志级别,包含 panic、error、info、debug、trace等
8. loglevel = "info"

10. # 程序中使用协程池的大小
11. gopoolsize = 50000

13. # 查询 TDengine 监控数据轮询间隔
14. RotationInterval = "15s"

16. [tdengine]
17. host = "127.0.0.1"
18. port = 6041
19. username = "root"
20. password = "taosdata"

22. # 需要被监控的 taosAdapter
23. [taosAdapter]
24. address = ["127.0.0.1:6041"]

26. [metrics]
27. # 监控指标前缀
28. prefix = "taos"

30. # 集群数据的标识符
31. cluster = "production"

33. # 存放监控数据的数据库
34. database = "log"

36. # 指定需要监控的普通表
37. tables = []

获取监控指标

taosKeeper 作为 TDengine 监控指标的导出工具,可以将 TDengine 产生的监控数据记录在指定数据库中,并提供导出接口。

查看监控结果集

1. $ taos
2. # 如上示例,使用 log 库作为监控日志存储位置
3. > use log;
4. > select * from cluster_info limit 1;

结果示例:

1. ts            |            first_ep            | first_ep_dnode_id |   version    |    master_uptime     | monitor_interval |  dbs_total  |  tbs_total  | stbs_total  | dnodes_total | dnodes_alive | mnodes_total | mnodes_alive | vgroups_total | vgroups_alive | vnodes_total | vnodes_alive | connections_total |  protocol   |           cluster_id           |
2. ===============================================================================================================================================================================================================================================================================================================================================================================
3. 2022-08-16 17:37:01.629 | hlb:6030                       |                 1 | 3.0.0.0      |              0.27250 |               15 |           2 |          27 |          38 |            1 |            1 |            1 |            1 |             4 |             4 |            4 |            4 |                14 |           1 | 5981392874047724755            |
4. Query OK, 1 rows in database (0.036162s)

导出监控指标

1. $ curl http://127.0.0.1:6043/metrics

部分结果集:

1. # HELP taos_cluster_info_connections_total
2. # TYPE taos_cluster_info_connections_total counter
3. taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16
4. # HELP taos_cluster_info_dbs_total
5. # TYPE taos_cluster_info_dbs_total counter
6. taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2
7. # HELP taos_cluster_info_dnodes_alive
8. # TYPE taos_cluster_info_dnodes_alive counter
9. taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1
10. # HELP taos_cluster_info_dnodes_total
11. # TYPE taos_cluster_info_dnodes_total counter
12. taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
13. # HELP taos_cluster_info_first_ep
14. # TYPE taos_cluster_info_first_ep gauge
15. taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1