三、安裝Grafana docker鏡像
3.1 docker pull grafana/grafana
$ docker pull grafana/grafana
[email protected]:~# docker pull grafana/grafana
Using default tag: latest
latest: Pulling from grafana/grafana
97518928ae5f: Pull complete
5b58818b7f48: Pull complete
d9a64d9fd162: Pull complete
4e368e1b924c: Pull complete
867f7fdd92d9: Pull complete
387c55415012: Pull complete
07f94c8f51cd: Pull complete
ce8cf00ff6aa: Pull complete
e44858b5f948: Pull complete
4000fdbdd2a3: Pull complete
Digest: sha256:18d94ae734accd66bccf22daed7bdb20c6b99aa0f2c687eea3ce4275fe275062
Status: Downloaded newer image for grafana/grafana:latest
[email protected]:~#
3.2 建立Grafana容器
docker run -d --name jmeter-grafana --restart=always -p 3000:3000 grafana/grafana
3.3 通路grafana
通路虛拟機ip:3000。
首次登入grafana後,需要修改密碼,預設登入賬密:admin/admin

選擇Prometheus
配置URL為Prometheus資料庫位址。如下圖:本文URL舉例:http://192.168.0.104:9090
點選測試通過,出現上圖的綠底白色對鈎即可。
3.4 在Grafana配置Jmeter壓測資料監控模闆
首先,在Grafana官網上搜尋jmeter模闆:
https://grafana.com/grafana/dashboards/?search=jmeter
在+号中選擇import:将number:13098拷貝到下圖中,點選Load:
點選import,導入模闆。
四、Jmeter配置Prometheus Listener
4.1 配置Prometheus Listener
JMeter添加後端監控器Prometheus Listener,需要先增加jmeter-prometheus-plugin插件。
插件位址:https://github.com/johrstrom/jmeter-prometheus-plugin/releases
将下載下傳好的"jmeter-prometheus-plugin-0.5.2.jar"
放入\apache-jmeter-5.0\apache-jmeter-5.0\lib\ext路徑下,這個路徑根據讀者本地路徑因人而異。
在jmeter腳本中的http請求内部,添加Listener中的Prometheus Listener。
配置Prometheus Listener中的參數,可視需要而定。
配置Prometheus Metrics
執行JMeter腳本,開始進行發壓。
通路http://localhost:9270/metrics位址,如果有資料則證明Prometheus已經可以采集到JMeter的發壓資料了。如下圖所示:
4.2 通路Grafana
檢視Prometheus:
檢視Grafana監控面闆:
至此,Jmeter + Prometheus+ Grafana的性能監控平台已經搭建完畢。
資源分享
下方這份完整的軟體測試視訊學習教程已經上傳CSDN官方認證的二維碼,朋友們如果需要可以自行免費領取
【保證100%免費】