Jmeter原生的实时监控每半分钟收集一次数据,只能在Linux控制台查看日志输出,界面看起来不直观,图表报告只能等压测结束后才能生成。以下图为jmeter在Linux下运行的实时日志:正则表达式
那么如何在压测过程当中实时生成图表监控数据呢?这里介绍一种实现方案:搭建Jmeter + Grafana + InfluxDB性能测试监控环境。数据库
BackendListener:Jmeter中的监听器浏览器
InfluxDB:存储实时数据的DBtcp
Grafana:DB中存储的实时数据能够在浏览器查看性能
cat << EOF | tee /etc/yum.repos.d/influxdb.repo测试
[influxdb]ui
name = InfluxDB Repository - RHEL \$releaseverurl
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stablespa
enabled = 1线程
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF
yum install -y influxdb
[root@localhost ~]# vi /etc/influxdb/influxdb.conf
# 找到graphite而且修改它的库与端口
[[graphite]]
enabled = true
database = "jmeter"
bind-address = ":2003"
protocol = "tcp"
consistency-level = "one"
[root@localhost ~]# /etc/init.d/influxdb restart
Stopping influxdb...
influxdb process was stopped [ OK ]
Starting influxdb...
influxdb process was started [ OK ]
yum install https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.1-1.x86_64.rpm
[root@localhost ~]# /etc/init.d/grafana-server restart
OKopping Grafana Server ... [ OK ]
Starting Grafana Server: .... OK
- 8086端口是Grafana用来从数据库取数据的端口
- 2003端口是Jmeter往数据库发数据的端口
图表配置比较麻烦,能够直接导入别人配置好的图表:https://grafana.com/dashboards/4026
大体介绍几种经常使用的监控:
名称 |
描述 |
jmeter.all.h.count |
全部请求的TPS |
jmeter.<请求名称>.h.count |
对应<请求名称>的TPS |
jmeter.all.ok.pct99 |
99%的请求响应时间 |
jmeter.<请求名称>.ok.pct99 |
对应<请求名称>99%的请求响应时间 |
jmeter.all.test.startedT |
线程数 |
若是要监控<请求名称>的话,Jmeter上的“Backend Listener”修改以下参数
1. 将“summanyOnly”修改为False,
2. 将“userRegexpForSamplersList”修改为True,
3. 而且要设置“samplersList”的值,“samplersList”是能够支持正则表达式的,“samplersList”的设置要与请求对应,不然找不到该请求。