小 T 導讀:taosKeeper 是 TDengine 3.0 的運行(xing)狀態指標(biao)監控工具,通過簡單的幾項配(pei)置即可(ke)(ke)獲取 TDengine 的運行(xing)狀態信息。其使用 TDengine RESTful 接口(kou),所以(yi)不需(xu)要(yao)安裝 TDengine 客戶端(duan)即可(ke)(ke)使用。本(ben)文將詳(xiang)細解讀 taosKeeper 的詳(xiang)細語法規則,方(fang)便有需(xu)要(yao)的用戶開(kai)展應用。
時序數據庫 TDengine( Time Series Database,TSDB) 通過 taosKeeper 將服務器的 CPU、內存、硬盤空間、帶寬、請求數、磁盤讀寫速度等信息定時寫入指定實時數據庫,也(ye)支(zhi)持對(dui)重要的(de)系統操(cao)作(比(bi)如登錄(lu)、創建、刪(shan)除數據庫(ku)等)以及各種錯誤報警信息進(jin)行記錄(lu)。系統管理員可(ke)以從命令行直接查看該數據庫(ku),也(ye)可(ke)以在 Web 端通(tong)過圖形(xing)化界面查看這些(xie)監(jian)測(ce)信息。這些(xie)監(jian)測(ce)信息的(de)采集缺(que)省是打開的(de),也(ye)可(ke)以通(tong)過修改配(pei)置文件(jian)里的(de)選(xuan)項(xiang) monitor 來關閉。
taosKeeper 安裝方式(shi):單獨編譯 taosKeeper 并安裝,詳情請參考 倉庫(ku)()。
配置和運行方式
taosKeeper 需要在(zai)操作系(xi)統終端中執行,該(gai)工具支持三(san)種配(pei)置方式:命令(ling)行參數、環(huan)境變量(liang)和配(pei)置文件。優先級為:命令(ling)行參數、環(huan)境變量(liang)、配(pei)置文件參數。
需要注意的是,在運行 taosKeeper 之前要確保 TDengine 集群與 taosAdapter 已經正確運行,并且 TDengine 已經開啟監控服務。監控配置可參考,具體的配置項包括 monitor、monitorFqdn、monitorPort、monitorInterval 和 telemetryReporting。
命令行參數啟動
可以直接執行 taosKeeper,也可以在執行命令時提供命令行參數。
$ taosKeeper
環境變量啟動
通(tong)過設置環(huan)境變量(liang)達到控制啟動參數的目的,通(tong)常在(zai)容器中運(yun)行(xing)時使用。
$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3
$ taoskeeper
具體參數列表請參照 taoskeeper -h 輸入結果。
配置文件啟動
執行以下命令即可快速體驗 taosKeeper。當不指定 taosKeeper 配置文件時,優先使用 /etc/taos/keeper.toml 配(pei)置(zhi),否則將使(shi)用(yong)默(mo)認(ren)配(pei)置(zhi)。
$ taoskeeper -c <keeper config file>
具體配置文件示例請參考:
獲取監控指標
taosKeeper 作為 TDengine 監控指標的導出工具,可以將 TDengine 產生的監控數據記錄在指定數據庫中,并提供導出接口(kou)。
查看監控結果集
$ taos
# 如上示例,使用 log 庫作為監控日志存儲位置
> use log;
> select * from cluster_info limit 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 |
===============================================================================================================================================================================================================================================================================================================================================================================
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)
導出監控指標
$ curl //127.0.0.1:6043/metrics
部分結果集:
# 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——使用監控數據庫 + Grafana 對 TDengine 進行監控的解決方案,下文將淺談一下 TDinsight 的前期部署和準備。在部署時,我們首先需要下載自動化腳本 TDinsight.sh:
wget //github.com/taosdata/grafanaplugin/raw/master/dashboards/TDinsight.sh
chmod +x TDinsight.sh
準備:
- TDengine Server 信息:
- TDengine RESTful 服務:使用參數
-a指定。如果是運行在同一主機,通常是//localhost:6041。 - TDengine 用戶名和密碼,使用
-u-p指定。
- TDengine RESTful 服務:使用參數
- Grafana 告警通知
- 使用已經存在的 Grafana Notification Channel
uid,參數-E。該參數可以使用curl -u admin:admin localhost:3000/api/alert-notifications |jq來獲取。JSON 解析工具jq可能需要單獨安裝。
- 使用已經存在的 Grafana Notification Channel
sudo ./TDinsight.sh -a //localhost:6041 -u root -p taosdata -E <notifier uid>
運行程序并重啟 Grafana 服務,打開面板://localhost:3000/d/tdinsight可以查看 TDengine 服務運行(xing)狀態。
監控(kong)數(shu)據庫為用(yong)戶提供了更多的監控(kong)項(xiang),與 taosKeeper 共同筑牢 TDengine 數(shu)據監控(kong)的城墻。在下一篇(pian)文章(zhang)中,我們將會(hui)詳解解說如(ru)何使(shi)用(yong) TDinsight 方案對 TDengine 進行監控(kong),敬(jing)請期待(dai)。


























