小 T 導讀:taosKeeper 是 TDengine 3.0 的運行狀態(tài)指標監(jiān)控工具,通過簡單的幾項配置即可獲取 TDengine 的運行狀態(tài)信息。其使用 TDengine RESTful 接口,所以不需要安裝 TDengine 客戶端即可使用。本文將詳細解讀 taosKeeper 的詳細語法規(guī)則,方便有需要的用戶開展應用。
時序數(shù)據(jù)庫 TDengine( Time Series Database,TSDB) 通過 taosKeeper 將服務器的 CPU、內(nèi)存、硬盤空間、帶寬、請求數(shù)、磁盤讀寫速度等信息定時寫入指定實時數(shù)據(jù)庫,也支持對重要的系統(tǒng)操作(比如登錄、創(chuàng)建、刪除數(shù)據(jù)庫等)以及各種錯誤報警信息進行記錄。系統(tǒng)管理員可以從命令行直接查看該數(shù)據(jù)庫,也可以在 Web 端通過圖形化界面查看這些監(jiān)測信息。這些監(jiān)測信息的采集缺省是打開的,也可以通過修改配置文件里的選項 monitor 來關(guān)閉。
taosKeeper 安裝方式:單獨編譯 taosKeeper 并安裝,詳情請參考 taosKeeper 倉庫(https://github.com/taosdata/taoskeeper)。
配置和運行方式
taosKeeper 需要在操作系統(tǒng)終端中執(zhí)行,該工具支持三種配置方式:命令行參數(shù)、環(huán)境變量和配置文件。優(yōu)先級為:命令行參數(shù)、環(huán)境變量、配置文件參數(shù)。
需要注意的是,在運行 taosKeeper 之前要確保 TDengine 集群與 taosAdapter 已經(jīng)正確運行,并且 TDengine 已經(jīng)開啟監(jiān)控服務。監(jiān)控配置可參考相關(guān)文檔,具體的配置項包括 monitor、monitorFqdn、monitorPort、monitorInterval 和 telemetryReporting。
命令行參數(shù)啟動
可以直接執(zhí)行 taosKeeper,也可以在執(zhí)行命令時提供命令行參數(shù)。
$ taosKeeper
環(huán)境變量啟動
通過設置環(huán)境變量達到控制啟動參數(shù)的目的,通常在容器中運行時使用。
$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3
$ taoskeeper
具體參數(shù)列表請參照 taoskeeper -h 輸入結(jié)果。
配置文件啟動
執(zhí)行以下命令即可快速體驗 taosKeeper。當不指定 taosKeeper 配置文件時,優(yōu)先使用 /etc/taos/keeper.toml 配置,否則將使用默認配置。
$ taoskeeper -c <keeper config file>
具體配置文件示例請參考:https://docs.taosdata.com/reference/taosKeeper/
獲取監(jiān)控指標
taosKeeper 作為 TDengine 監(jiān)控指標的導出工具,可以將 TDengine 產(chǎn)生的監(jiān)控數(shù)據(jù)記錄在指定數(shù)據(jù)庫中,并提供導出接口。
查看監(jiān)控結(jié)果集
$ taos
# 如上示例,使用 log 庫作為監(jiān)控日志存儲位置
> use log;
> select * from cluster_info limit 1;
結(jié)果示例:
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 |
===============================================================================================================================================================================================================================================================================================================================================================================
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 |
Query OK, 1 rows in database (0.036162s)
導出監(jiān)控指標
$ curl http://127.0.0.1:6043/metrics
部分結(jié)果集:
# HELP taos_cluster_info_connections_total
# TYPE taos_cluster_info_connections_total counter
taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16
# HELP taos_cluster_info_dbs_total
# TYPE taos_cluster_info_dbs_total counter
taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2
# HELP taos_cluster_info_dnodes_alive
# TYPE taos_cluster_info_dnodes_alive counter
taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1
# HELP taos_cluster_info_dnodes_total
# TYPE taos_cluster_info_dnodes_total counter
taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
# HELP taos_cluster_info_first_ep
# TYPE taos_cluster_info_first_ep gauge
taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1
TDinsight
除了 taosKeeper,TDengine 還提供了 TDinsight——使用監(jiān)控數(shù)據(jù)庫 + Grafana 對 TDengine 進行監(jiān)控的解決方案,下文將淺談一下 TDinsight 的前期部署和準備。在部署時,我們首先需要下載自動化腳本 TDinsight.sh:
wget https://github.com/taosdata/grafanaplugin/raw/master/dashboards/TDinsight.sh
chmod +x TDinsight.sh
準備:
- TDengine Server 信息:
- TDengine RESTful 服務:使用參數(shù)
-a指定。如果是運行在同一主機,通常是http://localhost:6041。 - TDengine 用戶名和密碼,使用
-u-p指定。
- TDengine RESTful 服務:使用參數(shù)
- Grafana 告警通知
- 使用已經(jīng)存在的 Grafana Notification Channel
uid,參數(shù)-E。該參數(shù)可以使用curl -u admin:admin localhost:3000/api/alert-notifications |jq來獲取。JSON 解析工具jq可能需要單獨安裝。
- 使用已經(jīng)存在的 Grafana Notification Channel
sudo ./TDinsight.sh -a http://localhost:6041 -u root -p taosdata -E <notifier uid>
運行程序并重啟 Grafana 服務,打開面板:http://localhost:3000/d/tdinsight可以查看 TDengine 服務運行狀態(tài)。
監(jiān)控數(shù)據(jù)庫為用戶提供了更多的監(jiān)控項,與 taosKeeper 共同筑牢 TDengine 數(shù)據(jù)監(jiān)控的城墻。在下一篇文章中,我們將會詳解解說如何使用 TDinsight 方案對 TDengine 進行監(jiān)控,敬請期待。



互聯(lián)網(wǎng).png)



-1.png)











伙伴.png)
伙伴.png)



