jmeter+influxdb+grafana性能測試監控
背景:
話說Jmeter原生的監控確實太醜了,聽大佬們在討論Jmeter+InfluxDb+Grafana的監控,於是,為了有一個漂亮的測試報告,就手動開始進行部署。
安裝步驟:
1、influxdb下載安裝:
[[email protected] ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.0.x86_64.rpm --no-check-certificate
[[email protected] ~]# rpm -ivh influxdb-1.7.0.x86_64.rpm
(如果未安裝wget,需要先安裝,安裝命令:[[email protected] ~]# yum search wget、[[email protected] ~]# yum install wget.x86_64)
安裝完之後,配置文件路徑為: /etc/influxdb/influxdb.conf
修改配置文件:
[[email protected] ~]# vi /etc/influxdb/influxdb.conf
在配置文件中找到graphite配置項
[[graphite]] # Determines whether the graphite endpoint is enabled. enabled = true database = "jmeter" # 數據庫名稱 retention-policy = "" bind-address = ":2003" # 端口 protocol = "tcp" consistency-level = "one" 修改HTTP端口信息 [http] # Determines whether HTTP endpoint is enabled. enabled = true # The bind address used by the HTTP service. bind-address = ":8086"
啟動influxd服務:
[[email protected] ~]# influxd &
influxDB的tcp端口:8088
[[email protected] ~]# netstat -anp|grep 8088
influxDB數據庫操作:
[[email protected] ~]# influx # 登錄數據庫 Connected to http://localhost:8086 version 1.6.0 InfluxDB shell version: 1.6.0 > show databases # 查看數據庫 name: databases name ---- _internal jmeter > create database "jmeter" # 創建數據庫 > use jmeter #切換數據庫 Using database jmeter > create user "admin" with password ‘123456‘ with all privileges # 創建管理員權限的用戶
開啟需要用到的接口:
[[email protected] ~]# firewall-cmd --zone=public --add-port=8086/tcp --permanent success [[email protected] ~]# firewall-cmd --zone=public --add-port=2003/tcp --permanent success [[email protected] ~]# firewall-cmd --zone=public --add-port=8088/tcp --permanent success [[email protected] ~]# firewall-cmd --reload success
2、Jmeter配置
創建一個測試計劃,並添加監聽器-Backend Listenter,Backend Listener implementation 選擇org.apache.jmeter.visualizers.backend.graphite.GraphiteBackendListenerClient
添加線程
設置influxDB IP及端口
運行測試,等待幾秒看數據
端口說明:
2003端口:Jmeter往數據庫發數據的端口
8086端口,Grafana從數據庫取數據的端口
查看Jmeter數據庫的表信息:
[[email protected] ~]# influx Connected to http://localhost:8086 version 1.6.0 InfluxDB shell version: 1.6.0 > show measurements ERR: database name required Warning: It is possible this error is due to not setting a database. Please set a database with the command "use <database>". > show databases name: databases name ---- _internal jmeter > use jmeter Using database jmeter > show measurements name: measurements name ---- jmeter.all.a.avg jmeter.all.a.count jmeter.all.a.max jmeter.all.a.min jmeter.all.a.pct90 jmeter.all.a.pct95 jmeter.all.a.pct99 jmeter.all.h.count jmeter.all.ko.avg jmeter.all.ko.count jmeter.all.ko.max jmeter.all.ko.min jmeter.all.ko.pct90 jmeter.all.ko.pct95 jmeter.all.ko.pct99 jmeter.all.ok.avg jmeter.all.ok.count jmeter.all.ok.max jmeter.all.ok.min jmeter.all.ok.pct90 jmeter.all.ok.pct95 jmeter.all.ok.pct99 jmeter.all.rb.bytes jmeter.all.sb.bytes jmeter.test.endedT jmeter.test.maxAT jmeter.test.meanAT jmeter.test.minAT jmeter.test.startedT
這個時候已經可以將統計數據成功發送到InfluxDB
3、Grafana和influxDB數據源配置
安裝Grafana:
官網:https://grafana.com/grafana/download
下載地址:https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.1-1.x86_64.rpm
安裝:rpm -ivh grafana-5.2.1-1.x86_64.rpm
(如果提示:
警告:grafana-5.2.1-1.x86_64.rpm: 頭V4 RSA/SHA1 Signature, 密鑰 ID 24098cb6: NOKEY
錯誤:依賴檢測失敗:
fontconfig 被 grafana-5.2.1-1.x86_64 需要
urw-fonts 被 grafana-5.2.1-1.x86_64 需要
執行命令:[[email protected] ~]# yum install fontconfig freetype* urw-fonts -y
後,再進行安裝
)
啟動
[[email protected] ~]# service grafana-server start
Starting Grafana Server: ... [ OK ]
開啟3000訪問端口:
[[email protected] benben]# firewall-cmd --zone=public --add-port=3000/tcp --permanent
success
[[email protected] benben]# firewall-cmd --reload
success
瀏覽器訪問:http://IP:3000/login
grafana的默認用戶名密碼都是admin,第一次登錄會要求更改密碼
創建influxDB數據源
單擊save & Test,提示:data source is working,說明保存和連接成功
創建dashboard
新建Graph面板
數據綁定
選擇influxdb的數據源庫名,jmeter的相關表
定義顯示的名稱
保存數據模板
直接按ctrl+s或點擊保存按鈕
說明:想要了解這些監控都代表什麽意思,可以訪問Jmeter的官網地址去查看閱讀“http://jmeter.apache.org/usermanual/realtime-results.html”
線程數/用戶相關指標 test.minAT-Min active threads:最小活躍線程數 test.maxAT-Max active threads:最大活躍線程數 test.meanAT-Mean active threads:活躍線程數 test.startedT-Started threads:啟動線程數 test.endedT-Finished threads:結束線程數 響應時間指標 .ok.count:采樣器的成功響應數 .h.count:每秒點擊數 .ok.min:采樣器成功最短響應時間 .ok.max:采樣器成功最長響應時間 .ok.avg:采樣器成功平均響應時間 .ok.pct:采樣器成功響應百分比 .ko.count:采樣器失敗響應數 .ko.min:采樣器失敗的響應最短時間 .ko.max:采樣稱失敗最長響應時間 .ko.avg:采樣器失敗平均響應時間 .ko.pct:采樣器失敗響應百分比 .a.count:采樣器響應數(ok.count和ko.count的總和) .a.min:采樣器最小響應時間(ok.count和ko.count的最小值) .a.max:采樣器最大響應時間(ok.count和ko.count的最大值) .a.avg:采樣器平均響應時間(ok.count和ko.count的平均值) .a.pct:采樣器響應百分比(根據和失敗樣本的總數計算) Backend Listener的默認百分位設置為“90;95;99”,即百分位數為90%,95%和99%。 Graphite使用點(“.”)去拆分的元素,這可能與十進制百分位值混淆。JMeter轉換任何此類值,用下劃線(“ - ”)替換點(“.”)。例如,“99.9 ”變為“99_9 ” 默認情況下,JMeter發送在samplerName“all”下累計的所有采樣器的指標。 如果配置了 BackendListenerSamplersList,那麽JMeter還會發送匹配樣本名稱的指標,前提是配置 summaryOnly=true
導入Dashboard模版
從Grafana官網下載相應的模板
官網模版庫:https://grafana.com/dashboards
搜索看板模版
下載:jmeter load test
下載的jar包復制到jmeter的/lib/ext下面
導入模板
加載模板文件,將下載的json文件打開,將源碼復制粘貼到第二個框中
選擇模板數據源
重啟jmeter,再添加一個後置處理器-Backend Listener,選擇rocks.nt.apm.jmeter.JMeterinfluxDBBackendListenerClient,輸入influxDB的host和端口,之前創建用戶名和密碼
壓測的效果圖
圖片和操作步驟轉自https://www.cnblogs.com/mike-liu/p/10080351.html博客,感謝!
jmeter+influxdb+grafana性能測試監控