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



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



-1.png)




.png)


證.png)


伙伴.png)
伙伴.png)
伙伴.png)



