Windows平臺的prometheus和Grafana的學習與使用

Windows平臺的prometheus和Grafana的學習與使用


背景

最近沒有了linux機器
突然想捯飭一下Windows平臺的監控與使用
所以總結一一下. 

第一步下載

https://prometheus.io/download/
https://grafana.com/grafana/download

注意需要下載 windows平臺的安裝介質
建議是選擇 zip包. 
zip包可以方便的設置目錄. 

啓動prometheus

解壓縮後進行處理, 比如我這邊的目錄爲:

E:\00Grafana 的目錄

2023/11/20  10:31    <DIR>          .
2023/11/20  10:31    <DIR>          data
2023/11/20  07:59    <DIR>          grafana
2023/11/20  07:58    <DIR>          prometheus

在prometheus 目錄下面執行腳本

prometheus.exe  --config.file="prometheus.yml"   --storage.tsdb.retention.time=2m  --storage.tsdb.retention.size=15GB  --storage.tsdb.path="E:\00Grafana\data"

然後就可以查看了.

http://127.0.0.1:9090

啓動grafana

進入 grafana/bin 目錄下
執行命令
grafana.exe server  就可以打開服務
默認用戶密碼
admin/admin
第一次登錄必須修改密碼 

然後可以導入就可以了. 

啓動windows-exporter

cmd 直接執行 windows_exporter-0.24.0-amd64.exe

就可以
默認監聽端口: 9182

修改prometheus增加配置

  - job_name: "Windows"
    static_configs:
      - targets: ["localhost:9182"]

grafana導入dashboard

https://grafana.com/grafana/dashboards/14694-windows-exporter-dashboard/

導入 14694 就可以
但是需要注意

14694 已經很久沒有在grafana官網上面更新了. 默認打開很多沒有數據. 最好是使用github上面的json文件:
https://github.com/rasoulivand/windows-exporter-dashboard

json文件的最後修改時間是 2023-06
grafana上面的最後修改時間是 2021-07

註冊爲服務

增加一個shell 腳本爲: 
@echo off
E:
cd E:\00Grafana\
E:\00Grafana\windows_exporter-0.24.0-amd64.exe 
文件保存到: 
E:\00Grafana\bin\windows_exporter.bat

使用 cmd 命令行模式常見服務
sc create Windows_Exporter binPath=E:\00Grafana\bin\windows_exporter.bat start= auto

其他兩個服務爲:
@echo off
E:
cd E:\00Grafana\prometheus
E:\00Grafana\prometheus\prometheus.exe  --config.file="E:\00Grafana\prometheus\prometheus.yml"   --storage.tsdb.retention.time=2m  --storage.tsdb.retention.size=15GB  --storage.tsdb.path="E:\00Grafana\data"

設置爲: E:\00Grafana\bin\prometheus.bat
設置服務: 
sc create prometheus binPath=E:\00Grafana\bin\prometheus.bat  start=auto

Grafana 

@echo off
E:
cd E:\00Grafana\grafana\bin
E:\00Grafana\grafana\bin\grafana.exe  server

設置爲: E:\00Grafana\bin\grafana.bat
設置服務: 
sc create grafana binPath=E:\00Grafana\bin\grafana.bat  start=auto

簡單效果

image

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章