通过案例带你轻松玩转JMeter连载(53)

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
可观测可视化 Grafana 版,10个用户账号 1个月
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 通过案例带你轻松玩转JMeter连载(53)

2被测端监控:Exporter + Prometheus + Grafana



上一节我们介绍了在压测端使用JMeter集群+Influxdb存储+Grafana实时数据展示进行监控压测端,这一节我们来介绍下在被测端的监控工具组合:Exporter + Prometheus + Grafana。


2.1 Exporter


在被测端,如果操作系统为Linux系统,对应的Exporter为node_exporter;如果操作系统为Windows系统,对应的Exporter为windows_exporter.exe。我们先来介绍node_exporter的安装。


1)node_exporter
node_exporter可通过以下几个步骤进行和下载和安装。

node_exporter-0.18.1.linux-amd64.tar.gz。

  • 运行命令“./node_exporter &”。
  • 打开浏览器,在浏览器地址中输入:192.168.1.3:9100。
  • 点击Metrics连接,可以看见node_exporter收集到的Linux信息。


2)windows_exporter.exe
windows_exporter可通过以下几个步骤进行下载和安装。

  • 下载windows_exporter.exe或者windows_exporter.msi。
  • 下载完毕后进行安装,默认安装地址为:C:\Program Files\windows_exporter\。
  • 进入安装目录,运行windows_exporter.exe。
  • 打开浏览器,在浏览器地址中输入:192.168.1.3:9182。如图14所示。

image.png

图14 windows_exporter主界面


注意node_exporter端口为9100,而windows_exporter为9182。

  • 点击Metrics可以显示收集到的Windows操作系统信息

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles
# TYPE go_gc_duration_seconds summarygo_gc_duration_seconds{quantile="0"} 0go_gc_duration_seconds{quantile="0.25"} 0go_gc_duration_seconds{quantile="0.5"} 0go_gc_duration_seconds{quantile="0.75"} 0go_gc_duration_seconds{quantile="1"} 0.0022913go_gc_duration_seconds_sum 0.0043842go_gc_duration_seconds_count 34…


其中。

  • HELP是解释下面指标的含义,相当于帮助文档。
  • TYPE用于解释指标的数据类型。
  • 下面的信息是具体的统计信息。


2.2 Prometheus


Prometheus 是由 SoundCloud 开源监控告警解决方案。


1)Prometheus Windows版本通过网页下载prometheus-2.27.1.windows-amd64;Liunx下通过以下命令来完成安装。

  • wget -c

https://github.com/prometheus/prometheus/releases/download/v2.15.1/prometheus-2.15.1.linux-amd64.tar.gz

  • tar zxvf prometheus-2.15.1.linux-amd64.tar.gz

2)修改prometheus.yml文件中的端口号。


scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from 
this config.
  - job_name: 'OS'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['127.0.0.1:9182']


在这里Windows下使用- targets: ['127.0.0.1:9182'],而Linux下使用- targets: ['127.0.0.1:9100']。


下面来简单介绍一下这个文件。

  • global:为全局配置,比如每次数据收集的间隔、规则扫描数据的间隔。
  • alerting:这里可以设置告警的插件,比如 alertmanager等。
  • rule_files:这里为具体的报警规则设置,比如基于什么指标进行报警,相当于触发器。
  • scrape_configs:采集数据的对象,job_name、target 以及 job_name 是配置主机的名称,target 是为安装的 Exporter 地址。

3)运行prometheus.exe,打开浏览器,在地址栏中输入:http://127.0.0.1:9090/targets,如图15所示。


image.png

图15 Prometheus主界面


在这个界面中我们可以看见windows_exporter.exe或node_exporter被Prometheus监控到。


2.3 Grafana


Grafana的安装我们在上一节中介绍过,现在让我们来看一下如何对Prometheus进行配置。


1)启动Grafana
2)打开浏览器,在地址栏中输入:http://127.0.0.1:3000/datasources/new,按下图输入Name,HTTP下的URL、Access。如图16所示。

image.png

图16 配置Grafana访问Prometheus信息


3)点击【Save & Test】,验证测试通过,如图17所示。

image.png

图17 验证配置Grafana访问Prometheus信息是否正确


4)接下来按照1.3第7)步,import windows_exporter.exe或node_exporter数据,如图18所示。

image.png

图18 import windows_exporter或node_exporter数据


注意:windows_exporter ID为10467,node_exporter ID为8919。可以通过https://grafana.com/grafana/dashboards/10467https://grafana.com/grafana/dashboards/8919来查看信息。


5)点击【Import】就可以看到监控信息了,如图19所示和图20所示。这里监控都是被测机器操作系统的数据,包括CPU、内存、网络、磁盘等信息。

image.png

图19 确认Import windows_exporter或node_exporter数据


image.png

图20 windows_exporter或node_exporter监控数据展示


2.4 配置MySQL监控


另外我们还可以来监控MySQL信息。
1)通过https://prometheus.io/download/来下载mysql_export。如图21所示。

image.png

图21 下载mysql_export


2)下载完毕,修改my.cnf文件,配置MySQL连接信息。


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


在这里host为MySQL所在的IP地址、port为端口号,默认是3306、user是MySQL的用户名、password是MySQL的密码。


3)通过运行mysqld_exporter.exe --config.my-cnf=my.cnf启动,启动后,在浏览器的地址栏中输入:http://127.0.0.1:9104/。得到图22所示。

image.png

图22 mysqld_exporter主界面


4)对prometheus.yml进行如下配置。


scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this 
config.
  - job_name: 'OS'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['127.0.0.1:9182']
  - job_name: 'MySql'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['127.0.0.1:9104']


5)重新启动prometheus.exe,在浏览器送输入http://127.0.0.1:9090/targets,得到图23界面。

image.png

图23 Prometheus主界面


在这个界面中我们可以看见mysqld_exporter被prometheus监控。


6)启动Grafana,Import mysql_exporter数据信息。如图24所示。

image.png

图24 import mysql_exporter数据


7)mysql_exporter节点为11323,可以通过https://grafana.com/grafana/dashboards/11323来查看


8)最后点击【Load】,仍旧选择Prometheus就可以看到mysql_exporter的信息了。如图25所示。


image.png

图25 mysql_exporter监控数据展示


关于Prometheus可以参考https://www.bookstack.cn/read/prometheus-book/README.md

目录
相关文章
|
存储 Linux
通过案例带你轻松玩转JMeter连载(60)
通过案例带你轻松玩转JMeter连载(60)
130 0
通过案例带你轻松玩转JMeter连载(60)
|
算法
通过案例带你轻松玩转JMeter连载(59)
通过案例带你轻松玩转JMeter连载(59)
177 0
通过案例带你轻松玩转JMeter连载(59)
|
XML JavaScript Java
通过案例带你轻松玩转JMeter连载(58)
通过案例带你轻松玩转JMeter连载(58)
102 0
通过案例带你轻松玩转JMeter连载(58)
通过案例带你轻松玩转JMeter连载(57)
通过案例带你轻松玩转JMeter连载(57)
93 0
通过案例带你轻松玩转JMeter连载(57)
|
存储 索引
通过案例带你轻松玩转JMeter连载(56)
通过案例带你轻松玩转JMeter连载(56)
87 0
通过案例带你轻松玩转JMeter连载(56)
|
存储 Prometheus 监控
通过案例带你轻松玩转JMeter连载(55)
通过案例带你轻松玩转JMeter连载(55)
114 0
通过案例带你轻松玩转JMeter连载(55)
|
存储 监控 数据可视化
通过案例带你轻松玩转JMeter连载(54)
通过案例带你轻松玩转JMeter连载(54)
118 0
通过案例带你轻松玩转JMeter连载(54)
|
JSON 监控 数据可视化
通过案例带你轻松玩转JMeter连载(52)
通过案例带你轻松玩转JMeter连载(52)
150 0
通过案例带你轻松玩转JMeter连载(52)
|
存储 监控 测试技术
通过案例带你轻松玩转JMeter连载(51)
通过案例带你轻松玩转JMeter连载(51)
170 0
通过案例带你轻松玩转JMeter连载(51)
|
Java 测试技术 Apache
通过案例带你轻松玩转JMeter连载(50)
通过案例带你轻松玩转JMeter连载(50)
174 0
通过案例带你轻松玩转JMeter连载(50)