当前位置:网站首页>Jmeter+grafana+influxdb build a visual performance test monitoring platform

Jmeter+grafana+influxdb build a visual performance test monitoring platform

2022-06-24 16:56:00 Tanyin

【 The background that 】

Use jmeter When performing a performance test , The way the tool comes with to view the results is often not intuitive and clear , So we need to build a visual monitoring platform to monitor the results , Here we use three JMeter+Grafana+Influxdb To complete the platform construction

【 Realization principle 】

adopt influxdb Database storage jmeter Result , Re pass grafana collection influxdb Database data , Complete the display of monitoring platform

【 Platform building 】

Method 1 :Windows or macOS Build... In the environment

1.InfluxDB install

First of all to enter influxDB Download the installation package on the official website

https://portal.influxdata.com/downloads/

Windows You can use the following link to download directly

https://dl.influxdata.com/influxdb/releases/influxdb-1.7.9_windows_amd64.zip

Decompress after downloading , With Windows For example :

After entering the folder, you can see the following directory

Click on influxd.exe Start database , Start successfully as shown in the figure below

Click on influx.exe Get into influxdb client , After entering, create the name as “jmeter” The database of

2.grafana install

First of all to enter grafana Download the installation package on the official website

https://grafana.com/grafana/download

Select the corresponding system and download , With Windows For example :

After decompression, enter bin Directory clicking grafana-server.exe To start up grafana Program

After startup, open the browser for input http://localhost:3000 Get into grafana The login page

The default username and password are admin, After entering the home page, click Add database

choice influxdb database , Fill in the following information

Click on sava&test, Show data source is working Indicates that the database connection is successful

Import the downloaded dashboard

You can also go to grafana Find templates on the official website , Enter the required template in the import template Downlosds Just number

https://grafana.com/grafana/dashboards

Finally, as shown in the figure

3.jmeter To configure

1.jmeter in , add to “ Monitor -> Back end listener ”

Configure the back-end listener , The purpose is to jmeter The results are stored in influxdb database

Method 2 :Linux Build... In the environment

1.influxdb install

Use the command to install influxdb

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.4_linux_amd64.tar.gz

decompression influxdb Compressed package

tar -zxvf influxdb-1.8.4_linux_amd64.tar.gz 

Add environment variables

cd influxdb-1.8.4-1/usr/bin
sudo cp {influx,influxd} /usr/local/bin/

start-up influxdb

influxd

start-up influxdb client , establish jmeter database

influx
create databases jmeter

2.grafana install

Use the command to install

wget https://dl.grafana.com/oss/release/grafana-7.5.2.linux-amd64.tar.gz

Unzip the installation package

tar -zxvf grafana-7.5.2.linux-amd64.tar.gz

start-up grafana

cd grafana-7.5.2/bin
./grafana-server

visit grafana Webpage , Other operations are the same as method 1

http://ip:3000

3.jdk+jmeter install

install jmeter It needs to be installed before jdk, download jdk( You can use the following address to download , You can also download it from the official website , You need to log in to the official website oracle)https://www.jdkdownload.com/, I choose jdk-8u181-linux-x64.tar.gz Version download

decompression jdk

tar -zxvf jdk-8u181-linux-x64.tar.gz

Configure environment variables , Modify the configuration file vi /etc/profile, Add the following at the end of the text

JAVA_HOME=/usr/local/java/jdk1.8.0_181
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH

Enable environment variables

source /etc/profile

verification jdk Configuration is successful

java -version

Use the command to install jmeter

wget https://mirrors.bfsu.edu.cn/apache//jmeter/binaries/apache-jmeter-5.4.1.tgz

decompression jmeter

tar -zxf apache-jmeter-5.4.1.tgz

To configure jmeter environment variable ,vi /etc/profile, Add the following at the end of the text

export JMETER_HOME=/usr/local/apache-jmeter-5.4.1
export CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$CLASSPATH
export PATH=$JMETER_HOME/bin:$PATH

Enable environment variables

source /etc/profile

verification jmeter Configuration is successful

jmeter --version

take jmeter Upload the script to the current folder , Execute the following command to start jmeter

jmeter -n -t ***.jmx -l test.jtl
 Parameter description :
-n  Not  GUI  Pattern  ->  In Africa  GUI  Run in mode  JMeter
-t  The test file  ->  To run  JMeter  Test script file 
-l  Log files  ->  Documentation of results 

Method 3 :docker Under the container

1.influxdb Install and run

docker run -itd --name influxdb -p 8086:8086 influxdb

Into the container

docker exec -it influxdb /bin/bash

Create database

influx
create database jmeter
show databases

2.grafana Install and run

docker run -itd --name grafana -p 3000:3000 grafana/grafana

Into the container

docker exec -it grafana /bin/bash

visit grafana Webpage , Other operations are the same as method 1

http://ip:3000

3.jmeter install

First you need to download jmeter

wget https://mirrors.bfsu.edu.cn/apache//jmeter/binaries/apache-jmeter-5.4.1.tgz

We use dockerfile install , The contents are as follows

FROM java:8

ENV http_proxy ""
ENV https_proxy ""

RUN mkdir /jmeterdocker
RUN mkdir -p /jmeterdocker/test
RUN mkdir -p /jmeterdocker/test/input/jmx
RUN mkdir -p /jmeterdocker/test/input/testdata
RUN mkdir -p /jmeterdocker/test/report/html
RUN mkdir -p /jmeterdocker/test/report/jtl
RUN mkdir -p /jmeterdocker/test/report/outputdata
RUN chmod -R 777 /jmeterdocker

ENV JMETER_VERSION=5.4.1
ENV JMETER_HOME=/jmeterdocker/apache-jmeter-${JMETER_VERSION}
ENV JMETER_PATH=${JMETER_HOME}/bin:${PATH}
ENV PATH=${JMETER_HOME}/bin:${PATH}

COPY apache-jmeter-${JMETER_VERSION}.tgz /jmeterdocker

RUN cd /jmeterdocker \
    && tar xvf apache-jmeter-${JMETER_VERSION}.tgz \
    && rm apache-jmeter-${JMETER_VERSION}.tgz

stay dockerfile Execute the command under the file path

docker build -t jmeter .

establish jmeter Containers

docker run -itd --name=jmeter -v /tmp/jmeterspace/test/input/jmx:/jmeterdocker/test/input/jmx \
            -v /tmp/jmeterspace/test/input/testdata:/jmeterdocker/test/input/testdata \
            -v /tmp/jmeterspace/test/report/html:/jmeterdocker/test/report/html \
            -v /tmp/jmeterspace/test/report/jtl:/jmeterdocker/test/report/jtl \
            -v /tmp/jmeterspace/test/report/outputputdata:/jmeterdocker/test/report/outputdata \
            -p 1099:1099 \
             jmeter

take jmeter The script is placed outside the container /tmp/jmeterspace/test/input/jmx Under the path

Into the container , Execute the following command

docker exec -it jmeter /bin/bash
cd /jmeterdocker/test/input/jmx
jmeter -n -t ***.jmx -l test.jtl
 Parameter description :
-n  Not  GUI  Pattern  ->  In Africa  GUI  Run in mode  JMeter
-t  The test file  ->  To run  JMeter  Test script file 
-l  Log files  ->  Documentation of results 

The results are shown in the figure

【 summary 】

The above three methods can be completed JMeter+Grafana+Influxdb Platform building , Here, you can select the corresponding installation method according to your needs

原网站

版权声明
本文为[Tanyin]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/04/20210403111047570K.html