Noga Cohen is a Sr. Product Marketing Manager for CA BlazeMeter. She manages the BlazeMeter blog and other content activities. Noga focuses on creating technological content in the fields of performance, load testing and API testing, both independently and by managing writers who are developers. Noga has more than 5 years of experience in a wide scope of writing techniques: hi-tech, business, journalist and academic.

Learn JMeter in 5 Hours

Start Learning
Slack

Run massively scalable performance tests on web, mobile, and APIs

Apr 13 2017

How to Use the Ultimate Thread Group, the RegEx Extractor and the JSON Path Extractor in Apache JMeter

Apache JMeter™ enables you to create many types of advanced and complex test scenarios. In this blog post we will go over three advanced elements: the Ultimate Thread Group, the RegEx Extractor and the JSON Path Extractor.

 

The Ultimate Thread Group

 

JMeter’s Ultimate Thread Group is an element that enables sophisticated management of the thread groups in your load. This is done by enabling you to have an infinite number of rows in the thread schedule, which enables different configurations for different parts of the Thread Group.

 

First, make sure you installed JMeter plugins.

 

Right click -> Add-> Threads -> Ultimate Thread Group

 

jmeter add ultimate thread group

 

Add as many thread counts as you need, and choose the delay, startup time, hold time and shutdown time for each row.

 

As you can see, this element has a graph at the bottom that visualizes the load. If you change the numbers, the visualization will change as well.

 

jmeter ultimate thread group

 

jmeter ultimate thread group graph

 

The visualization is a helpful way for seeing the loads we are putting on our system. For example, if we are stress testing the system or if we are accurately simulating our visitors’ usage patterns.

 

Click here to learn about JMeter’s Stepping Thread Group and the Concurrency Thread Group.

 

The Regular Expression Extractor

 

JMeter’s Regular Expression Extractor is an element that lets you extract information from responses. This is useful way for ensuring your pages respond with the information you need them to respond.

 

1. Add a Thread Group

 

2. Add a HTTP Request as a Child Element of the Thread Group. In this case, we will test our demo page www.blazedemo.com

 

jmeter add http request

 

3. Add a Regular Expression Extractor - Right Click -> Post Processors -> Regular Expression Extractor

 

jmeter add regular expression extractor

 

4. We can look for responses in the body, the body unescaped, the body as a document, the response headers, the request headers, the URL, the response code or the response message. In this case we will look at the body.

 

jmeter regular expression extractor

  • Name the Reference, for your convenience
  • In the ‘Regular Expression’ field insert the test you’re looking for. In this case, we put in the words ‘Welcome’.
  • Template: $0$ - grabs the entire array; $1$ - looks at the first item in the array.
  • Match No. (0 for Random): This is important if the response shows up a number of times on the page. 0 - choose a random response; - choose the first response.
  • Default Value: The value if the response isn’t found. We recommend you don’t leave this part blank. If you put ‘NOT FOUND’ it’s easier to debug.

 

jmeter regular expression extractor

 

5. Add a listener and a Debug Sampler. The Debug Sampler will show the values of the variables from the test run.

 

We can see that the results came back and that the RegEx came back as “Welcome”.

 

jmeter view results tree

 

If the extractor doesn’t find what we want, the result would come back as “Not Found”, like here:

 

jmeter regex extractor results not found

 

The JSON Path Extractor

 

JMeter’s JSON Path Extractor is an element for extracting responses from JSON responses. Compared to the RegEx Extractor, it is more resource intensive, so if you can use the RegEx Extractor, we recommend you do so.

 

1. First, make sure you installed JMeter plugins.

 

2. Add a Thread Group.

 

3. Add a Dummy Sampler to your Thread Group - Right Click -> Add-> Sampler -> Dummy  Sampler

 

jmeter add dummy sampler

 

The Dummy Sampler lets us send any result we want, and is therefore useful for troubleshooting.


4. Insert your JSON payload as the Response Data.

 

jmeter insert json payload


5. Add the JSON Path Extractor - Right Click -> Add -> Post Processors -> JSON Path Extractor

 

jmeter add json path extractor

  • Choose a Destination Variable Name, for your convenience
  • JSONPath Expression: Tell JMeter what to find in the JSON. In this case, any first name among all employees.
  • Default Value: Like in the RegEx Extractor, we put in ‘NOT FOUND’.

 

jmeter json path extractor


6. Add a Debug Sampler and a View Results Tree Listener

 

We can see we got two results back - John and Anna, like we requested.

 

jmeter json path extractor view results tree

 

For more information about the JSON Path Extractor, see here.

 

For more information about advanced load testing with JMeter, check out this free webinar, or view the  webinar "Advanced JMeter Scripting and Continuous Integration Performance Testing, here.

 

BlazeMeter enhances JMeter’s abilities by running JMX tests in the cloud and providing rich reports. Start testing now - just put your URL or JMX file in the box right here and your test will start in minutes. Or, request a BlazeMeter demo.

 

Interested in writing for our Blog?Send us a pitch!

Your email is required to complete the test. If you proceed, your test will be aborted.