熱門搜索 Zabbix技術(shù)資料 Zabbix常見問、答討論 成功案例 Zabbix交流區(qū) Prometheus交流區(qū)
這一期主要來(lái)跟大家聊一下,使用node_exporter工具來(lái)暴露主機(jī)和因公程序上的指標(biāo),利用prometheus來(lái)監(jiān)控宿主機(jī);以及通過通過Cadvisor監(jiān)控docker容器。
# 1 下載軟件包
wget http://github.com/prometheus/node_exporter/releases/download/v1.4.0/node_exporter-1.4.0.linux-amd64.tar.gz
# 創(chuàng)建node exporter運(yùn)行目錄
mkdir -p /usr/local/node_exporter
tar -xf node_exporter-1.4.0.linux-amd64.tar.gz
cd node_exporter-1.4.0.linux-amd64 && mv ./* /usr/local/node_exporter
#驗(yàn)證
./node_exporter --version
./node_expoter –help
#默認(rèn)運(yùn)行端口
–web.listen-address=”:9100″
# 暴露指標(biāo)的路徑
–web.telemetry-path=”/metrics”
#注意:通過配置參數(shù),可以決定啟用哪些收集器。
#啟動(dòng)node_exporter,可以指定參數(shù)進(jìn)行覆蓋
nohup ./node_exporter –web.listen-address=”:9600″
–web.telemetry-path=”/metrics” &
#查看是否啟動(dòng)完成 ps -ef | grep node_exporter
說(shuō)明: textfile收集器允許我們暴露自定義指標(biāo),這些自定義指標(biāo)可能是批處理或cron作業(yè)無(wú)法抓取的,或者是沒有可用的exporter
原理:收集器通過掃描指定目錄中的問津,提取所有格式為prometheus指標(biāo)的字符串,然后暴露他們以便被prometheus sever抓取
1) 創(chuàng)建收集器目錄
mkdir /usr/local/node_exporter/textfile_collector
2) 創(chuàng)建新指標(biāo),注意指標(biāo)在以.prom結(jié)尾的文件內(nèi)定義
echo ‘metadata{role=”docker”,data_center=”ShangHai”} 2’ >metadata.prom
3) 啟動(dòng)textfile收集器
textfile收集器不需要配置參數(shù),默認(rèn)就會(huì)被加載,我們?cè)趩?dòng)node_exporter的時(shí)候,指定textfile收集器的目錄即可
參數(shù):
collector.textfile.directory
啟動(dòng)
nohup ./node_exporter –web.listen-address=”:9600″ –web.telemetry-path=”/metrics” –collector.textfile.directory=”/usr/local/node_exporter/textfile_collector” &
說(shuō)明: systemd收集器記錄了systemd管理的服務(wù),通過–collector.systemd.unit-whitelist參數(shù)指定需要收集的服務(wù),按需收集
啟動(dòng):
nohup ./node_exporter –web.listen-address=”:9600″ –web.telemetry-path=”/metrics” –collector.textfile.directory=”/usr/local/node_exporter/textfile_collector” –collector.systemd –collector.systemd.unit-whitelist=”(docker|sshd|rsyslog).service” &
配置prometheus對(duì)node_exporter進(jìn)行指標(biāo)采集
? – job_name: “node_exporter”
? ? static_configs:
? ? ? – targets: [“192.168.161.118:9600”]? ? ? ? #這個(gè)端口盡量使用默認(rèn)端口9100,方便辨認(rèn)
docker run
-v /:/rootfs:ro
-v /var/run:/var/run/:rw
-v /sys:/sys:ro
-v /dev/disk:/dev/disk:ro
-v /home/docker:/var/lib/docker:ro
-p 8080:8080
–detach=true –name=cadvisor –net=host google/cadvisor
#注意:/home/docker為實(shí)際部署的docker數(shù)據(jù)目錄,默認(rèn)應(yīng)該為/var/lib/docker
?驗(yàn)證:
?查看指標(biāo):
http://192.168.161.118:8080/metrics
配置prometheus server抓取CAdvisor
配置prometheus.yml配置文件
熱重啟prometheus
#prometheus server啟動(dòng)開啟熱更新配置
參數(shù):–web.enable-lifecycle
nohup ./prometheus –web.enable-lifecycle –config.file=prometheus.yml &
#熱重啟prometheus
curl -X POST http://192.168.161.118:9090/-/reload
查看prometheus 的targets,即可發(fā)現(xiàn),docker容器監(jiān)控完成,到此本期的分享就結(jié)束了,更多關(guān)于prometheus的干貨分享,可以持續(xù)關(guān)注尊龍時(shí)凱社區(qū),或者尊龍時(shí)凱官網(wǎng)的prometheus技術(shù)分享專欄。
通過Nginx反向代理是一個(gè)不錯(cuò)的選擇。 本文尊龍時(shí)凱君將介紹通過Nginx反向代理增加401認(rèn)證方式來(lái)實(shí)現(xiàn)加密登錄。
View details這一期尊龍時(shí)凱君主要跟大家來(lái)探討新一代的開源監(jiān)控prometheus,我們知道 zabbix 在監(jiān)控界占有不可撼動(dòng)的地位,功能強(qiáng)大。但是對(duì)容器監(jiān)控顯得力不從心。為解決監(jiān)...
View detailsZabbix對(duì)接Prometheus實(shí)操教程
View details監(jiān)控了內(nèi)蒙、昌平、上海、貴州四區(qū)域核心機(jī)房,主機(jī)對(duì)象30000左右,數(shù)據(jù)日增量約100G。
View details尊龍時(shí)凱為該公司部署了集中監(jiān)控、集中告警、可視化試圖、多樣性報(bào)表和大屏展示等功能。
View details尊龍時(shí)凱為該公司部署了集中監(jiān)控、告警系統(tǒng),并配置了可視化視圖和多樣性報(bào)表。
View details尊龍時(shí)凱對(duì)主機(jī)、網(wǎng)絡(luò)、存儲(chǔ)、數(shù)據(jù)庫(kù)、中間件、應(yīng)用、硬件、虛擬化、攝像頭及其他數(shù)據(jù)感知設(shè)備等實(shí)現(xiàn)一站式監(jiān)控,保障業(yè)務(wù)高效穩(wěn)定的運(yùn)行。
View details