JMeter+InfluxDB+Grafana視覺化實時監控平臺(六)
1、InfluxDB安裝與使用
Windows安裝
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.4.2_windows_amd64.zip
unzip influxdb-1.4.2_windows_amd64.zip
Linux安裝
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.6.2.x86_64.rpm
sudo yum localinstall influxdb-1.6.2.x86_64.rpm
InfluxDB配置:influxdb/influxdb.conf
Jmeter使用graphite協議去寫入資料到InfluxDB,因此,需要在InfluxDB配置檔案啟用它,如下圖所示:
[[graphite]]
enabled = true
bind-address = ":2003"
database = "jmeter"
retention-policy = ""
protocol = "tcp"
batch-size = 5000
batch-pending = 10
batch-timeout = "1s"
consistency-level = "one"
separator = "."
udp-read-buffer = 0
啟動:
Windows:D:\grafana\influxdb-1.8.1-1>influxd -config influxdb.conf
Linux:influxd -config /etc/influxdb/influxdb.conf
環境變數配置:
Windows-Path:, D:\grafana\influxdb-1.8.1-1\influxdb.conf
Linux: $INFLUXDB_CONFIG_PATH = /etc/influxdb/influxdb.conf
InfluxDB操作
D:\grafana\influxdb-1.8.1-1>influx Connected to http://localhost:8086 version 1.8.1 InfluxDB shell version: 1.8.1 > show databases #檢視所有資料庫 name: databases name ---- _internal > CREATE DATABASE "jmeter" #建立資料庫 > use jmeter #切換資料庫 Using database jmeter > CREATE USER "admin" WITH PASSWORD 'admin' WITH ALL PRIVILEGES # 建立管理員許可權的使用者
2、JMeter&InfluxDB整合
Jmeter配置
(1)建立一個測試計劃,並新增Backend Listener
(2)設定InfluxDB IP及埠設定
(3)執行測試,等待幾秒執行測試,等待幾秒
(4)檢視JMeter是否生成錯誤日誌檢視JMeter是否生成錯誤日誌
執行壓測後InfluDB查詢
OK,我們已經可以將統計指標資料成功傳送到InfluxDB
埠說明:
2003埠,JMeter往資料庫發資料的埠
8086埠,Grafana用來從資料庫取資料的埠
3、Grafana&InfluxDB整合
(1) 什麼是Grafana?
Grafana是一個開源軟體,擁有豐富的指標儀表盤和圖形編輯器,適用Graphite, Elasticsearch, OpenTSDB, Prometheus,InfluxDB。簡單點說就是一套開源WEB視覺化平臺。
官網地址:https://grafana.com/
(2)Grafana安裝與啟動
Windows:
Wget
https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.3.windows-x64.zip
unzip grafana-4.6.3.windows-x64.zip
Windows切換到Grafana安裝目錄中的bin目錄下,雙擊grafana-server.exe啟動程式
Linux:
wget https://dl.grafana.com/oss/release/grafana-7.2.1.linux-amd64.tar.gz
tar -zxvf grafana-7.2.1.linux-amd64.tar.gz
Linux啟動:
service grafana-server start
Starting grafana-server (via systemctl): [ OK ]
(3) Grafana使用指南
>1. 開啟Google Chrome,輸入http://localhost:3000 , 使用admin/admin登入本機Grafana,新建influxdb資料來源。
第一步:登入Grafana。
第二步,建立資料來源
>2. 建立dashboard(新建或者匯入)
匯入模板地址: https://grafana.com/grafana/dashboards挑選下載模板(.json檔案)
4.執行壓力測試實時檢視效能監控平臺效果圖
Jmeter啟動壓測指令碼
平臺監控
親測總結,不足之處後續補充!