目前市面上的主流是以Liunx系統服務器爲主,可是仍存在使用windows系統服務器的企業,下面的內容將介紹如何基於Grafana+Prometheus 實現windows服務器,數據庫監控。python
一、Windows系統性能指標採集器mysql
#下載地址:https://github.com/martinlindhe/wmi_exporter/releases #選擇最新msi文件下載安裝便可。經過訪問http://ip+默認端口9182(如:http://localhost:9182) 出現下圖,即表明安裝採集數據成功。
二、Mysql數據指標採集器git
#下載地址:https://prometheus.io/download/ #找到mysqld_exporter採集器,選擇windows 版本便可 (如:mysqld_exporter-0.11.0.windows-amd64.tar.gz)
,在mysqld_exporter.exe的同級目錄下建立.my.cnf 並啓動github
.my.cnf中內容:web
[client] host=127.0.0.1 #mysql ip user=root #帳號 password=123456 #密碼
三、Prometheussql
#下載地址:https://prometheus.io/download/ #選擇windows 版本便可
a.下載解壓後,修改配置文件,修改新增mysql、windows數據採集器配置:數據庫
scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'windows' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9182'] - job_name: 'mysql' static_configs: - targets: ['localhost:3306']
b、啓動,cmd進入安裝目錄(& – -> 後臺運行)windows
prometheus.exe --config.file=prometheus.yml --web.listen-address=:9090 &
c、訪問 http://ip:9090 ,(如:http://localhost:9090)出現以下界面即爲prometheus安裝成功、數據採集器驗證成功 (PS: up爲成功,down 爲不成功。)瀏覽器
三、Grafana服務器
#下載地址:https://grafana.com/grafana/download #選擇windows 版本便可
解壓完成,進入bin目錄啓動grafana-server.exe 打開瀏覽器訪問 http://ip:3000,(如:http://localhost:3000) 用戶名/密碼 admin/admin
一、配置數據源
Configuration -- Add data source --- Prometheus , 輸入名稱,prometheus的訪問url ,點擊保存測試,驗證是否成功
二、選擇監控儀表盤模板導入。
訪問地址:https://grafana.com/dashboards --- serch框輸入windows ---- 選擇心儀模板 (注意模板所支持的數據源爲prometheus) ----- 進行 ID 或者JOSN文件兩種方式導入。
三、展現數據
模板導入成功便可看到監控數據
PS : MySQL性能數據展現步驟一致。