性能测试--基于Grafana+Prometheus 实现window服务器,数据库监控

基于Grafana+Prometheus 实现Windows服务器,MySQL数据库监控

目前市面上的主流是以Liunx系统服务器为主,但是仍存在使用windows系统服务器的企业,下面的内容将介绍如何基于Grafana+Prometheus 实现windows服务器,数据库监控。

一、简介

  • Grafana是一个开源的时序性统计和监控平台,支持例如 elasticsearch、graphite、influxdb 等众多的数据源,并以功能强大的界面编辑器著称
  • Prometheus最初在SoundCloud上构建的开源系统监视和警报工具包,拥有一个完整的监控和趋势系统,包括基于时间序列数据的内置和主动抓取,存储,查询,绘图和警报。

二、下载安装

1、Windows系统性能指标采集器

#下载地址:https://github.com/martinlindhe/wmi_exporter/releases
#选择最新msi文件下载安装即可。通过访问http://ip+默认端口9182(如:http://localhost:9182) 出现下图,即代表安装采集数据成功。

 2、Mysql数据指标采集器

#下载地址:https://prometheus.io/download/        
#找到mysqld_exporter采集器,选择windows 版本即可 (如:mysqld_exporter-0.11.0.windows-amd64.tar.gz)

在mysqld_exporter.exe的同级目录下创建.my.cnf 并启动

 .my.cnf中内容:

[client]
host=127.0.0.1        #mysql ip
user=root                #账号
password=123456    #密码

3、Prometheus

#下载地址: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进入安装目录(& – -> 后台运行)

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

c、访问 http://ip:9090 ,(如:http://localhost:9090)出现如下界面即为prometheus安装成功、数据采集器验证成功 (PS: up为成功,down 为不成功。)

 3、Grafana

#下载地址:https://grafana.com/grafana/download    
#选择windows 版本即可

解压完成,进入bin目录启动grafana-server.exe     打开浏览器访问 http://ip:3000,(如:http://localhost:3000) 用户名/密码 admin/admin

三、性能数据展示

1、配置数据源 

 Configuration  --   Add data source ---  Prometheus , 输入名称,prometheus的访问url ,点击保存测试,验证是否成功

 2、选择监控仪表盘模板导入。   

访问地址:https://grafana.com/dashboards  ---  serch框输入windows  ----  选择心仪模板 (注意模板所支持的数据源为prometheus)  -----   进行 ID 或者JOSN文件两种方式导入。

3、展示数据

模板导入成功即可看到监控数据

猜你喜欢

转载自www.cnblogs.com/doumingyi/p/12457863.html