基于Grafana+Prometheus 實(shí)現(xiàn)Windows服務(wù)器、MySQL數(shù)據(jù)庫(kù)監(jiān)控

目前市面上的主流是以Liunx系統(tǒng)服務(wù)器為主,但是仍存在使用windows系統(tǒng)服務(wù)器的企業(yè),下面的內(nèi)容將介紹如何基于Grafana+Prometheus 實(shí)現(xiàn)windows服務(wù)器,數(shù)據(jù)庫(kù)監(jiān)控。

一、簡(jiǎn)介

  • Grafana是一個(gè)開源的時(shí)序性統(tǒng)計(jì)和監(jiān)控平臺(tái),支持例如 elasticsearch、graphite、influxdb 等眾多的數(shù)據(jù)源,并以功能強(qiáng)大的界面編輯器著稱
  • Prometheus最初在SoundCloud上構(gòu)建的開源系統(tǒng)監(jiān)視和警報(bào)工具包,擁有一個(gè)完整的監(jiān)控和趨勢(shì)系統(tǒng),包括基于時(shí)間序列數(shù)據(jù)的內(nèi)置和主動(dòng)抓取,存儲(chǔ),查詢,繪圖和警報(bào)。

二、下載安裝

1、Windows系統(tǒng)性能指標(biāo)采集器

選擇最新msi文件下載安裝即可。通過訪問http://ip+默認(rèn)端口9182(如:http://localhost:9182) 出現(xiàn)下圖,即代表安裝采集數(shù)據(jù)成功。

2、Mysql數(shù)據(jù)指標(biāo)采集器

找到mysqld_exporter采集器,選擇windows 版本即可 (如:mysqld_exporter-0.11.0.windows-amd64.tar.gz)
在mysqld_exporter.exe的同級(jí)目錄下創(chuàng)建.my.cnf 并啟動(dòng)

.my.cnf中內(nèi)容:

[client]
host=127.0.0.1
port=3306
user=root
password=123456

3、Prometheus

選擇windows 版本即可`

a.下載解壓后,修改配置文件,修改新增mysql、windows數(shù)據(jù)采集器配置:

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
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:9104']

b、啟動(dòng),cmd進(jìn)入安裝目錄(& – -> 后臺(tái)運(yùn)行)

prometheus.exe --config.file=prometheus.yml --web.listen-address=:9090 &

c、訪問 http://ip:9090 ,(如:http://localhost:9090)出現(xiàn)如下界面即為prometheus安裝成功、數(shù)據(jù)采集器驗(yàn)證成功 (PS: up為成功,down 為不成功。)

image

3、Grafana

選擇windows 版本即可
解壓完成,進(jìn)入bin目錄啟動(dòng)grafana-server.exe 打開瀏覽器訪問 http://ip:3000,(如:http://localhost:3000) 用戶名/密碼 admin/admin

三、性能數(shù)據(jù)展示

1、配置數(shù)據(jù)源

Configuration -- Add data source --- Prometheus , 輸入名稱,prometheus的訪問url ,點(diǎn)擊保存測(cè)試,驗(yàn)證是否成功

2、選擇監(jiān)控儀表盤模板導(dǎo)入

訪問地址:https://grafana.com/grafana/dashboards/10467
這里不使用windows node,而使用國(guó)人制作的這個(gè)面板

3、展示數(shù)據(jù)

模板導(dǎo)入成功即可看到監(jiān)控?cái)?shù)據(jù)


4、使用prometheus的mysql exporter監(jiān)控mysql

在被監(jiān)控端mysql服務(wù)器上創(chuàng)建賬號(hào)用于mysql exporter收集使用

GRANT REPLICATION CLIENT, PROCESS ON  *.*  to 'exporter'@'%' identified by '123456';
GRANT SELECT ON performance_schema.* TO 'exporter'@'%';
flush privileges;

下載Mysql Overview:https://grafana.com/grafana/dashboards/7362
之后導(dǎo)入即可,效果圖如下

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容