In-depth good article [jmeter performance test and influxdb2 integration display monitoring results]

Jmeter is the most commonly used performance testing tool, and influxdb2 is a time series database.

There are a lot of materials in China that introduce the integration of jmeter and influxdb version 1.x. However, in 2021, influxdb will be upgraded to version 2.x. This version has structural adjustments with version 1.x and is completely incompatible. Using the previous material, the two cannot be integrated.

This article refers to a large number of official information and organizes the most complete integrated solution in China. I hope it will be helpful to everyone.

install influxdb2

rpm package installation

# 页面地址 https://github.com/influxdata/influxdb/releases
wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.2.0.x86_64.rpm

yum localinstall influxdb2-2.2.0.x86_64.rpm -y

# 启动influxdb2
systemctl start influxdb
# 或者 service influxdb start
# 或者 influxdb run

# 查看状态
systemctl status influxdb
# 或者 service influxdb status

docker installation

mkdir /opt/influxdb-docker-data-volume && cd $_
docker run -itd --name influxdb2 -p 8086:8086 --volume $PWD:/var/lib/influxdb2 influxdb:2.2.0

Configure influxdb2 authentication information

Browser access http://influxdb2_ip:8086

 

 

 

 

view token

 

View bucket-id

 

View userid and orgid

 

View influxdb2 built-in monitoring

 

 

Monitoring with influxdb2

Ⅰ. Only want to monitor the hardware resource usage of the server under test

Install telegraf on the machine you want to be monitored

# centos && RHEL
cat <<EOF | sudo tee /etc/yum.repos.d/influxdata.repo
[influxdata]
name = InfluxData Repository - Stable
baseurl = https://repos.influxdata.com/stable/\$basearch/main
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF
sudo yum install telegraf -y
# ubuntu && debain
wget -qO- https://repos.influxdata.com/influxdb.key | sudo tee /etc/apt/trusted.gpg.d/influxdata.asc >/dev/null
echo "deb https://repos.influxdata.com/debian stable main" | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf -y

In the UI platform of influxdb2, enter Telegraf, click create configuration

 

 

  • After creation, don’t rush to close the information on this interface
  • Copy the above export information to the clipboard, and then execute it on the server you want to be monitored;
  • Then, copy the telegraf sentence and execute it on the machine you want to be monitored

 

 

At this point, the hardware resource usage of the monitored machine has been collected. On the UI interface of influxdb2, click Boards and select system

 

 

Here it automatically shows us the hardware resource usage of the monitored machine.

If you want to monitor more than one machine, you only need to execute the export and telegraf commands on each machine according to telegraf. Multiple machines, in this monitoring interface, are marked with different colors in the chart.

Ⅱ. I want the grafana+influxdb2 integrated monitoring platform to monitor the hardware resource usage of the server under test

install grafana

  • Execute the installation
# centos && RHEL
wget https://dl.grafana.com/oss/release/grafana-8.5.0-1.x86_64.rpm
sudo yum install grafana-8.5.0-1.x86_64.rpm -y

## ubuntu && debain
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_8.5.0_amd64.deb
sudo dpkg -i grafana_8.5.0_amd64.deb

Note: Because you want to use influxdb2, please use the new version of grafana instead of the old lower version, which does not support influxdb2.

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

Configure grafana

  • Browser access http://grafana_ip:3000 admin/admin
  • add data source

 

Note that the boundary page information must be accurate

 

import template 14126

 

Enter 14126 and click load

 

Note, select the data source of influxdb2, import

 

 

In this way, we can check the hardware resource usage of the monitored machine on the grafana platform.

If there are multiple monitored machines, log out of grafana and log in again, open this panel, switch the host value in the upper right corner of the top, and you can switch to view the monitoring data of different machines.

Ⅲ. I want grafana+influxdb2+jmeter integrated monitoring platform to monitor performance test process data

Install influx-cli and create jmeter database

mkdir ../influx-cli && cd $_
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.3.0-linux-amd64.tar.gz

tar -xzvf influxdb2-client-2.3.0-linux-amd64.tar.gz
cd influxdb2-client-2.3.0-linux-amd64

./influx config create --config-name influx-cli-config \
--host-url http://127.0.0.1:8086 \
--org lemon \
--token Cfq2_NRU_0UZzm5uzwROaXdOevurmTg43b0kNFP6_leHIxn9ZRUzmrzKYP3NkhSMGMdrwXld6kPFyAYmLqyfGw== \
--active


./influx v1 dbrp create \
  --db jmeter \
  --rp jmeter \
  --bucket-id fab7c7508bef96f3 \
  --default

Write jmeter performance test data into influxdb2 library

  • Use jmeter5.4.1 or above
  • Add backend listener Method 1: Listener implementation selection: org.apache.jmeter.visualizers.backend.influxdb.InfluxdbBackendListenerClient influxbdUrl: http://You_Influxdb2_ip:8086/write?db=jmeter&org=You_Org&bucket=You_Bucket application:
  • Voluntary modification to add influxdbToken: You_APIToken

 

  • Execute the performance test. At this time, if there is no error in the parameter configuration, the data has been written into the influxdb2 database. In any machine terminal window that can connect to the influxdb2 database, execute curl --get http://You_Influxdb2_ip:8086/query \ - -header "Authorization: Token You_APIToken" \ --data-urlencode "q=select * from jmeter.jmeter.jmeter order by time desc limit 2;" # This sql means, look at the jmeter table in the jmeter library, in reverse order of time 2 pieces of data # sql statement can be modified by yourself, similar to relational database sql
  • You can view the latest 2 pieces of data written in the database

 

The added backend listener can also choose another implementation

  • Method 2: Listener implementation selection: org.apache.jmeter.visualizers.backend.influxdb.InfluxDB Raw BackendListenerClient
  • influxbdUrl:http://You_Influxdb2_ip:8086/write?db=jmeter&org=You_Org&bucket=You_Bucket
  • influxdbToken: You_APIToken
  • Add application: influxdb2 (custom value)

 

Executing performance tests, you can still write data into the influxdb2 database.

Grafana integrates with influxdb2 to display jmeter test data

  • First, install grafana and configure the influxdb2 data source
  • import template 5496

 

 

Embarrassment, great embarrassment, no data can come out

 

 

 

The reason is simple, because this template is based on influxdb1.x version and does not support influxdb2 version. You need to modify it yourself.

 

For students who don't know how to modify it, you can also use the following method instead:

  • download jdk11
  • Download the jmeter-plugin-influxdb2-listener-1.5.jar package and put it in the lib\ext folder of jmeter
  • Unzip and install jdk11, no need to configure system environment variables
  • Modify the jmeter startup file in the jmeter bin folder, start jmeter # windows ->jmeter.bat add set JAVA_HOME=the path where you installed jdk11 in front of the valid information of the file set PATH=%JAVA_HOME%\bin;%PATH% # mac && linux ->jmeter adds JAVA_HOME=your decompressed jdk11 path in front of the effective information of the file
  • In jmeter's backend listener, select the backend listener implementation: org.md.jmeter.influxdb2.visualizer.InfluxDatabaseBackendListenerClient

 

  • Note that the information in the red box is filled in correctly
  • jmeter performs performance testing
  • Import template 13644 in grafana

 

Note, choose a good data source, import

 

So far, we have used jmeter to integrate influxdb2 and grafana to build a monitoring platform, and the monitoring performance test process data has been fully realized.

Guess you like

Origin blog.csdn.net/Androidyuexia/article/details/131206489