Jmeter+Influxdb+Grafana平台监控性能测试过程(三种方式)

一、Jmeter自带插件监控

下载地址:Install :: JMeter-Plugins.org

安装:下载后文件为jmeter-plugins-manager-1.3.jar,将其放入jmeter安装目录下的lib/ext目录,然后重启jmeter,即可。

启动Jmeter,测试计划-->选择监听器jp@gc - Transactions per Second 、jp@gc - Response Times Over Time,测试接口性能

jp@gc - Transactions per Second ,接口的TPS

jp@gc - Response Times Over Time ,接口响应时间

二、Jmeter非GUI方式监控

cmd窗口执行非GUI方式: jmeter -n -t api.jmx -l \report\jtl -e -o \report\html

三、Jmeter+Influxdb+Grafana平台监控

1、背景

测试人员用Jmeter工具对相应的接口做负载测试和性能测试时,可以帮助我们发现应用程序中的性能瓶颈,但是Jmeter本身的聚合报告存在一些缺点,例如只能自己查看,无法实时共享,以及报告信息展示比较单一,不直观。

2、引入Grafana+Influxdb的作用及原理

2-1、grafana和Influxdb可以解决这个问题,grafana是一款采用Go语言编写的开源应用,主要用于大规模指标数据的可视化展示,Influxdb是一款时序性数据库,有时间戳组件,时间的方式去存储数据。

2-2、原理图

性能监控平台搭建中,可以将Jmeter获取的性能结果导入InfluxDB,再使用Grafana从InfluxDB中获取数据,用特定的模板进行展示,从而实现性能监控过程的可视化。

3、环境与配置

4、Influxdb数据库下载,启动,操作

4-1、下载Influxdb安装包(Influxdb2.0)

root@centos7 tools\]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.0_linux_amd64.tar.gz ![](https://img-blog.csdnimg.cn/img_convert/11393250f2f53d924b6a0a6dc8a42b5b.png) 4-2、解压Influxdb \[root@centos7 tools\]# tar -xzvf influxdb-1.8.0_linux_amd64.tar.gz ![](https://img-blog.csdnimg.cn/img_convert/b8da00eff97ac444adac13768c538290.png) 4-3、添加环境变量 \[root@centos7 tools\]# sudo ./influxdb/usr/bin/influxd /usr/local/bin/ 4-4、启动Influxd 添加环境变量后,Influxd可以在任意目录下启动。默认启动的端口为8086 **可以带配置启动:\[root@centos7 bin\]# ./influxd -config /home/tools/influxdb/etc/influxdb/influxdb.conf \&** ![](https://img-blog.csdnimg.cn/img_convert/984628f41eb768257010de66068cbb77.png) 4-5、 添加数据库及配置 创建Jmeter数据库。--\> Jmeter 数据存储到这里。 ![](https://img-blog.csdnimg.cn/img_convert/599a72b951360ade67c7718a0ea4d1d6.png) 5、Grafana平台下载,启动及配置 5-1、下载Grafana安装包(版本:9.4.9) \[root@centos71 tools\]# wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.4.9.linux-amd64.tar.gz ![](https://img-blog.csdnimg.cn/img_convert/7f734e081422555dbce4cf8a6dbc6f46.png) 5-2、解压Grafana \[root@centos71 tools\]# tar -xzvf grafana-enterprise-9.4.9.linux-amd64.tar.gz ![](https://img-blog.csdnimg.cn/img_convert/2c3dd86c0596395d3614c19ba492b069.png) 5-3、启动Grafana 默认端口为:3000,如果修改默认端口的话,进入grafana/conf; \[root@centos71 conf\]# vi defaults.ini 修改 http_port = 8000,保存defaults.ini文件 \[root@centos71 bin\]# ./grafana-server \& ![](https://img-blog.csdnimg.cn/img_convert/2901c58cfee87ff11c3b80cdafd4348d.png) ![](https://img-blog.csdnimg.cn/img_convert/15b95fcfc7272fba382e2e66bb1962a0.png) 浏览器打开:[http://192.168.124.130:8000/](http://192.168.124.130:8000/ "http://192.168.124.130:8000/"),如果打不开排查下是否Linux的防火墙是否打开,如果打开的话,我们直接关闭防火墙 \[root@centos71 bin\]# systemctl status firewalld ---查看防火墙状态 ![](https://img-blog.csdnimg.cn/img_convert/7cf46400395639f508ff993b42b510f2.png) \[root@centos71 bin\]# systemctl stop firewalld ---关闭防火墙 打开后的页面,Grafana默认账号密码为admin / admin ![](https://img-blog.csdnimg.cn/img_convert/3a837cacae72a3ee3fc88ccff87812e0.png) Grafana登录后的页面展示 ![](https://img-blog.csdnimg.cn/img_convert/ade1a7cec2204870f7b0e287a52e71dc.png) 5-4、下载jmeter模板 搜索模板:[Grafana dashboards \| Grafana Labs](https://grafana.com/grafana/dashboards/?search=jmeter "Grafana dashboards | Grafana Labs") ![](https://img-blog.csdnimg.cn/img_convert/f9d7ca010fe1142d102fdab6a9cf4ea9.png) 下载模板的JOSN文件,地址:[Apache JMeter Dashboard using Core InfluxdbBackendListenerClient \| Grafana Labs](https://grafana.com/grafana/dashboards/5496-apache-jmeter-dashboard-by-ubikloadpack/ "Apache JMeter Dashboard using Core InfluxdbBackendListenerClient | Grafana Labs") 或者复制模板ID:**5496** ![](https://img-blog.csdnimg.cn/img_convert/b54335a95a89b75b898517bab2674f60.png) 5-5、配置Influx数据源 进入Grafana首页,点击设置-\> Configuration -\> Data Sources -\> Add data source ![](https://img-blog.csdnimg.cn/img_convert/5f98d8f30d9047108e49540b43060328.png) 点击InfluxBD数据源 ![](https://img-blog.csdnimg.cn/img_convert/5efdebfffad0eb7365d61df1ac8eb63c.png) 填写InfluxDB的信息 ![](https://img-blog.csdnimg.cn/img_convert/00513b04ee50644f1de0a85ad8b9a580.png) ![](https://img-blog.csdnimg.cn/img_convert/cf0b9d4b5639d7b272203c5898f6f9f7.png) 5-6、导入Jmeter模板 ![](https://img-blog.csdnimg.cn/img_convert/cffeb73cf9d2a91aa266531d96ea3e87.png) 我使用的复制模板编码:**5496,再点击Load按钮** ![](https://img-blog.csdnimg.cn/img_convert/ccc174144f8520103460ef68edf3ddc7.png) 最终导入模板的效果显示 ![](https://img-blog.csdnimg.cn/img_convert/b0d6bba2d1d945d8ea0d4f62bc858d02.png) 6、Jmeter配置执行 测试计划中添加:Add -\> Listener -\> Backend Listener(后端监听器) ![](https://img-blog.csdnimg.cn/img_convert/48f80e401cd2c497637165e6998e1e5a.png) 执行Api测试(总详情), 总的请求数据959,错误请求1个,错误率为0.10%,结果如下: ![](https://img-blog.csdnimg.cn/img_convert/8b9a6badbb7ce0a4572ffeaba45a6798.png) ![](https://img-blog.csdnimg.cn/img_convert/c6a0275d84ccbb6153c72adb2918bb3a.png) **登录接口对比** ![](https://img-blog.csdnimg.cn/img_convert/0436213bdc14c2cd1c9ae2cbd12999e7.png) ![](https://img-blog.csdnimg.cn/img_convert/86c74eab78c52e9e23ade313981e143c.png) **查看所有书籍信息接口对比** ![](https://img-blog.csdnimg.cn/img_convert/d8b7e3b794be73b7752897f7e260895c.png) ![](https://img-blog.csdnimg.cn/img_convert/a87a2ca9dbb245a9f4e8d1c8a6bb1678.png) **添加书籍接口对比** ![](https://img-blog.csdnimg.cn/img_convert/a7272fe560fcbe0d1dff72adcdd14d23.png) ![](https://img-blog.csdnimg.cn/img_convert/42231e9ae3770d2a2a3f8bbd7ea91b74.png) **查看添加的数据信息接口对比** ![](https://img-blog.csdnimg.cn/img_convert/10467e6355b476bcebf2b0c2131c8d2d.png) ![](https://img-blog.csdnimg.cn/img_convert/0d5a10a69e26734afe2aa21e5a184716.png) **修改书籍信息接口对比** ![](https://img-blog.csdnimg.cn/img_convert/b45a21b8f06cd7e7e7bca0eead1fa253.png) ![](https://img-blog.csdnimg.cn/img_convert/b5898ba60d2003b0111dae94a77714e7.png) **删除书籍信息接口对比** ![](https://img-blog.csdnimg.cn/img_convert/21b079e78e89ebfcbfd178249535560d.png) ![](https://img-blog.csdnimg.cn/img_convert/13f830dd222b42d90ed08a2eb649ca8c.png) **验证书籍被删除接口对比** ![](https://img-blog.csdnimg.cn/img_convert/fd2ece1023c8b1a812f1159792f0fc25.png) ![](https://img-blog.csdnimg.cn/img_convert/532f7b8a91ca2b65733b9ce00db57b36.png) 这是我整理的**《2024最新Python自动化测试全套教程》** ,以及配套的接口文档/项目实战**【网盘资源】** ,需要的朋友可以**下方视频的置顶评论获取**。肯定会给你带来帮助和方向。 【已更新】B站讲的最详细的Python接口自动化测试实战教程全集(实战最新版)

相关推荐
软件测试大叔2 小时前
arm服务器运行Jmeter报错问题UseG1GC
jmeter
海姐软件测试7 小时前
使用Jmeter做功能测试有哪些优点?
功能测试·jmeter
碧水澜庭1 天前
Prometheus+ Grafana 监控系统入门
grafana·prometheus
遇见火星1 天前
一键部署Prometheus+Grafana+alertmanager对网站状态进行监控
grafana·prometheus
上海运维Q先生1 天前
Cilium动手实验室: 精通之旅---19.Golden Signals with Hubble and Grafana
云原生·k8s·grafana·cilium
奈斯ing1 天前
【prometheus+Grafana篇】基于Prometheus+Grafana实现Redis数据库的监控与可视化
数据库·redis·缓存·grafana·prometheus
smileNicky1 天前
Prometheus + Grafana 监控 RabbitMQ 实践指南
rabbitmq·grafana·prometheus
明月与玄武3 天前
JMeter 实现 MQTT 协议压力测试 !
jmeter·压力测试·jmeter实现 mqtt协议
文小大3 天前
五、jmeter脚本参数化
jmeter
程序员的世界你不懂3 天前
Jmeter(四) - 如何在jmeter中创建网络测试计划
jmeter