background
In daily work, Jmeter is often used for pressure measurement. After all, LR requires money (@¥&*…) , and the most commonly used interface pressure test, we are through aggregation report to view the pressure test results, but goose aggregation report is really ugly home, as a program ape this of course can not tolerate! So how do we make it look better?
How to transform?
way | advantages | disadvantages | scenario |
Jmeter+ant+Jenkins | Quick and easy to use | The report is not beautiful enough, intuitive, if the test interface is more than one, the report will show bloated not intuitive | Look at the final report |
Grafana+Jmeter+Influxdb (recommended) | Data visualization, intuitive data, powerful screening function, strong expansion ability | Also, learn about the Influxdb syntax, common query statements, and system methods….. | Look at the change of parameters during the manometry |
Tool is introduced
tool | introduce |
Jmeter | Stress Testing tools developed in the Java language |
InfluxDB | Go language development of an open source distributed timing database, very suitable for storing indicators, events, analysis and other data |
Grafana | A front-end tool for pure Javascript development, used to access InfluxDB, customize reports, display charts, and more |
Centos7 installation InfluxDB
Note: the blogger is his own ali cloud server ha, will not introduce how to install under the virtual machine (after all, virtual machine many pits…)
InfluxDB website to download path: portal.influxdata.com/downloads/
1. Run the following command to install:
Wget https://dl.influxdata.com/influxdb/releases/influxdb-1.6.3.x86_64.rpm sudo yum localinstall Influxdb - 1.6.3. X86_64. RPMCopy the code
2. After the installation is complete, modify the configuration of InfluxDB, mainly configuring the database and port numbers stored in JMeter
vim /etc/influxdb/influxdb.conf
Copy the code
3, find Graphite and modify its library and port
enabled = true
database = "jmeter"
retention-policy = ""
bind-address = ":2003"
protocol = "tcp"
consistency-level = "one
Copy the code
4. Find HTTP and remove the # from it
Now the new version of InfluxDB has removed its own data visualization interface, and the old version still has it. You can find admin, remove the # in front of it, and open its UI port. (This step is optional!)
View our database and data using the InfluxDB visual tool. See this blog post for installation and simple use:www.cnblogs.com/poloyy/p/12…
[admin]
# Determines whether the admin service is enabled.
enabled = true
# The default bind address used by the admin service.
bind-address = ":8083"
Copy the code
6. After the configuration is successful, start InfluxDB
Start command: systemctl start influxdb.service
Command to view the status: systemctl status Influxdb. service
Here, InfluxDB is installed and configured!! * : ஐ ٩ (๑ ´ ᵕ `) ۶ ஐ : *
Special note:
- Port 8083: indicates the port displayed on the InfluxDB UI
- Port 8086: The port Grafana uses to fetch data from the database
- 2003 port: the port on which Jmeter sends data to the database, just set up
Centos7 installation Grafana
Grafana can be downloaded from grafana.com/grafana/dow…
1. Run the following command to install:
Wget https://dl.grafana.com/oss/release/grafana-6.5.2-1.x86_64.rpm sudo yum localinstall grafana - tactical fix packs for 6.5.2-1. X86_64. RPMCopy the code
2, and then start
Start the systemctl start grafana-server.service command
To check the status, run the systemctl status grafana-server.service command
3. Access THE IP address and port xxx.xx.xx.xx:3000 and enter the user name and password to log in to the system. User name and password are “admin”, if you can open the page has been successful! But… How could it be so easy to install an environment?
4, when you check the status is active but access 3000 failed, it is possible that your 3000 port is not open!
Follow this article to operate can open 3000 port: www.cnblogs.com/poloyy/p/12…
5. Access IP plus port xx.xx.xx.xx:3000, if you can access grafana is successful!
Configuring Jmeter
How to install Jmeter? How to collect data by Jmeter
Step 1: Add a Listener – Backend Listener to a thread group
Step 2: Configure Backend Listener
As you can see, the Jmeter Implementatin GraphiteBackendListenerClient is selected by default, it is Jmeter 2.13 began to provide; In the Jmeter 3.2 adds one more InfluxDBBackendListenerClient, ah ~ what is the difference between the two? More on that later!
Here first selected GraphiteBackendListenerClient, the meaning of each configuration items
- GraphiteHost: IP address of the installed server
- GraphitePort: port; The default is 2003, unless you have set other ports when installing the InfluxDB.
- RootMetricsPrefix: indicates the root prefix of an indicator. When storing test results in a database, different metrics generate different tables, but these tables should all have a common prefix, which is this one; We’ll talk about what the different indicators mean (important)
- SummaryOnly: When you have multiple requests and want to know the results of each request, it’s best to specify false because true will only return a summary report of all requests, not a summary report of each request
- SamplersList: list of samplers; Fill in as many requests as you want to collect, preferably with regex matches to reduce the workload
- UseRegexpForSamplersList: Whether to use the re. If true, samplersList can match regular expressions
- Percentiles: percentage; That is, 90% Line, 95% Line, 99% Line data in similar aggregation reports; If you want 99.9, write [99_9] with underscores instead of dots
Suggestion: If you want to see the result data of each request, you can configure it according to my screenshot. Just change the samplerList to match the requests you need to monitor, nothing else!
Step 3: Run the Jmeter script to view the database
When I started, my database had only two tables, so I just ran get and POST requests
If successful on behalf of the result data are saved into InfluxDB inside, then let’s take a look at using GraphiteBackendListenerClient generates which tables?
Jmeter.all, jmeter.get, jmeter.post; Finally, there is actually a table starting with jmeter.test, which will be covered separately later
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
=== If you do not want to understand the specific meaning of each indicator, you can skip the following
=== Directly click the directory on the right to jump to Grafana configuration and see the next step
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Step 4: Definition of fine product indicators
Why does every table have a Jmeter prefix?
Backend Listener in Jmeter sets rootMetricsPrefix to Jmeter. You can change the value of rootMetricsPrefix in Backend Listener if you do not like the prefix or remember other names
<rootMetricsPrefix><samplerName>.ok.count. RootMetricsPrefix and samplerName are variables and can be configured
Next, let’s explain what each prefix means
Jmeter. all: represents all requests; When summaryOnly=true, there are only tables with samplerName=all
Jmeter. get: indicates that the HTTP request name is GET, i.e. SamplerName = GET
Jmeter. post: indicates that the HTTP request name is POST, i.e. samplerName= POST
Note: If one of your HTTP requests is called a GET request, your database will generate tables prefixed with jmeter.get requests
And then say what they mean for the different metrics
Highlight: All metrics here are translated directly from Jmeter official documents
Like English friends can see: jmeter.apache.org/usermanual/…
Thread/Virtual Users Metrics – Thread/Virtual Users metrics
Related to thread group Settings
indicators | The full name | meaning |
test.minAT | Min active threads | Minimum number of active threads |
test.maxAT | Max active threads | Maximum number of active threads |
test.meanAT | Mean active threads | Average number of active threads |
test.startedT | Started threads | Number of started threads |
test.endedT | Finished threads | Number of terminated threads |
Response Times metrics – Response time metrics
Highlight: Each Sampler contains all response time metrics, and each metric of each Sampler has a separate table to store the result data
indicators | meaning |
.ok.count | The number of successful responses of sampler |
.h.count | Hits per second (hits per second, or TPS) |
.ok.min | Minimum response time for a successful sampler response |
.ok.max | The maximum response time for a successful sampler response |
.ok.avg | Average response time for successful sampler responses |
.ok.pct | Percentage of successful sampler responses |
.ko.count | The number of failed responses in sampler |
.ko.min | Minimum response time for sampler response failure |
.ko.max | Maximum response time of a sampler response failure |
.ko.avg | Average response time of sampler response failures |
.ko.pct | Percentage of sampler responses that failed |
.a.count | Number of sampler responses (ok.count+ko.count) |
.sb.bytes | Sent bytes |
.rb.bytes | Received byte |
.a.min | Minimum response time for the Sampler response (minimum values for ok.count and ko.count) |
.a.max | Maximum response time of the Sampler response (maximum ok. Count and ko. Count) |
.a.avg | Average response time of sampler responses (average of ok. Count and Ko. Count) |
.a.pct | Percentage of Sampler responses (calculated based on the total number of successes and failures) |
Don’t know whether you have a question, why arjun, arjun ax, a.a in vg clearly said is the average response time, but the comments in brackets is and response related; But Jmeter’s official documentation explains that the translation is exactly that… Just wait for me to find out!
After my “careful” comparison, it can be found that the official website is indeed wrong ha, the real situation is as follows!
A.min: is the minimum of ok.min and ko.min
A.max: is the minimum of ok. Max and Ko. Max
A. avg: is the average value of OK. avg and Ko. Avg
The next step is to illustrate the facts with data! Look at the chart in the order of the indicators above!
However, the blogger is not sure if this comparison is completely scientifically correct, but as verified by the blogger, my correction is correct!
Attached is the comparison picture translated according to the official documentation. It can be seen that if a.max is used, it has nothing to do with OK. Count and Ko. Count
Configuration Grafana
If you go to the Grafana homepage, you can see the official process: first create the data source, then create the data panel
Creating a data source
You can click Create Your First Data Source on the home page, or you can look at the second image and follow the steps to enter the Create page
Then, select InfluxDB as our data source
At this point, the data source is configured successfully!!
Configure data kanban
Grafana&InfluxDB integration to display test result data
Basic use of panel
Follow the above steps to create a DashBoard, and then display specific data through the panel. First, introduce the entrance of the panel
Think like a computer scientist. You can switch to each other after you think like a computer scientist
Convert to row is to generate a row, you can display almost the same type of data in the panel, unified management, or expand;
As shown below, I have placed the panel describing the number of threads and the number of responses on the same Row
Data binding
View the total number of threads, number of successful responses, and number of failed responses
You can start by clicking Add Query to go to the screen below
To view the number of successful and failed responses, you only need to switch the table name.
You can see that it’s not quite the same as when I started showing just numbers, because the chart type hasn’t been set yet; When we just want to look at the data rather than the trend chart, we can change its type;
In the same interface, click the left list to select the second icon, and then select Singlestat
View TPS for all requests, GET requests, and POST requests
If you want to display multiple metrics in the same panel, you can Add Query to the Panel
Basic data binding has taught you that you can just change the name of the table that you want to display, okay
Along with the official provided a data kanban chart, you can also copy its panel, manually add each indicator
The Grafana+Jmeter+Influxdb real-time monitoring platform has been built.
Blogger, of course, it is not suggested to use GraphiteBackendListenerClient Jmeter to collect data, because the request more time there will be a lot of table, maintenance costs will increase; Behind will introduce how to collect data through InfluxDBBackendListenerClient
Configuration Backend InfluxDBBackendListenerClient Listener
Description of configuration Items
Let’s start by looking at what each configuration item means
- InfluxdbUrl: Indicates the path where the influxDB is installed. Main format: http://host address :8086/write? Db = Database name
- Application: indicates the application name. The corresponding field in the Events table is Application
- Measurement: table name; The default table is Jmeter. You don’t need to change it
- SummaryOnly: with GraphiteBackendListenerClient
- SamplersRegex: with GraphiteBackendListenerClient
- Percentiles: with GraphiteBackendListenerClient
- TestTitle: test name; The corresponding field in the Events table is text, and JMeter automatically generates comments at the start and end of the test with values ending in ‘start’ and ‘end’
- EventTags: Grafana allows you to display a label for each annotation; The corresponding field in the Events table is tags
If you don’t understand Application and testTitle, you can see that the time difference between two records of the same testTitle is the total time taken to execute the test plan
Suggestion: Just modify application and testTitle, which can be the same or different, and follow the picture for other configurations. Of course, the installation path should be changed
Check the InfluxDB
Also use InfluxDBBackendListenerClient benefit is, the more request will only generate two tables:
Events: Mainly stores events
Jmeter: Stores the test result data. Grafana also gets the data from this table and presents it
Grafana&InfluxDB were integrated again to display the test result data
This wouldn’t need to create a DashBoard and a Panel, because the official template library, already has a very perfect template, of course if you want to use InfluxDBBackendListenerClient collection of data to be effective
First, enter the official template library: grafana.com/dashboards…
As long as your data source and table name are correctly configured, Jmeter will execute the test plan again and filter the time in DashBoard to see the data successfully.
The template comes with three drop-down filters
Data_source: Data source, displayed as many as configured in Grafana
Application: If the application configured in Jmeter is different each time the test plan is executed, you can use this to filter out the result data for the corresponding test time
Transaction: A sampleList is configured in Jmeter. For example, if I only send get and POST requests, I will only select GET and POST. You can slide down to the bottom of the page to see a presentation of the data for a particular request
In fact, there is still a lot of room for improvement in this template, so you need to be familiar with the various uses of Grafana. In the future, we will add an article on common and advanced uses of Grafana. Stay tuned!