Question

I would like to take some metrics of a PHP application under load. To do that , I'm generating a lot of request on my webapp. In the webapp I'm collecting metrics (execution time, API request latency etc...), which are returned to the response via FirePHP headers. In the JMeter plan, I would like to collect those informations and either directly process them to produce a graph or alternatively store them in a log file .

The response headers looks like this :

...
X-Wf-1-1-1-31: 610|[{"Type":"LOG","File":"somescript.php","Line":7},{"duration":"1.7108917236328 ms","notes":{"invokation":["Solr_Connector::exec","somescript2.php line : 42"],"size_download":"2167 bytes","query":"...url data ..."},"name":"[tag1][tag2]SOLR REQUEST 1382626844.906"}]|
X-Wf-1-1-1-32: 611|[{"Type":"LOG","File":"somescript.php","Line":7},{"duration":"1.7011165618896 ms","notes":{"invokation":["Solr_Connector::exec","somescript2.php line : 42"],"size_download":"2590 bytes","query":"...url data ..."},"name":"[tag1][tag3]SOLR REQUEST 1382626844.9079"}]|
X-Wf-1-1-1-33: 611|[{"Type":"LOG","File":"somescript.php","Line":7},{"duration":"1.5978813171387 ms","notes":{"invokation":["Solr_Connector::exec","somescript2.php line : 42"],"size_download":"2452 bytes","query":"...url data ..."},"name":"[tag1][tag3]SOLR REQUEST 1382626844.9097"}]|
X-Wf-1-1-1-34: 610|[{"Type":"LOG","File":"somescript.php","Line":7},{"duration":"1.662015914917 ms","notes":{"invokation":["Solr_Connector::exec","somescript2.php line : 42"],"size_download":"3150 bytes","query":"...url data ..."},"name":"[tag1][tag2]SOLR REQUEST 1382626844.9115"}]|
...

How can I set up the JMeter regular expression extractor in order to extract all the values of the header whose names starts with "X-Wf-" ?

Was it helpful?

Solution

I understand Response headers will be:

Response headers:

HTTP/1.1 200 OK

Server: Apache-Coyote/1.1

X-Wf-1-1-1-31: 610|[{"Type":"LOG","File":"somescript.php","Line":7},{"duration":"1.7108917236328 ms","notes":{"invokation":["Solr_Connector::exec","somescript2.php line : 42"],"size_download":"2167 bytes","query":"...url data ..."},"name":"[tag1][tag2]SOLR REQUEST 1382626844.906"}]|

X-Wf-1-1-1-32: 611|[{"Type":"LOG","File":"somescript.php","Line":7},{"duration":"1.7011165618896 ms","notes":{"invokation":["Solr_Connector::exec","somescript2.php line : 42"],"size_download":"2590 bytes","query":"...url data ..."},"name":"[tag1][tag3]SOLR REQUEST 1382626844.9079"}]

...

Organize the Test Plan this way: Test Plan overview

  • Regextractor will extract headers to variables called headers_1, headers_2...

RegExtractor configuration

  • For Each Controller will iterator over headers_i and expose header variable

ForEach Controller configuration

  • JSR223 Sampler using Groovy will write header (exposed by For EachController) to file

JSR223 Sampler

Code:

import org.apache.commons.io.FileUtils;

FileUtils.write(new File("/results.csv"), vars["header"]+"\r\n","UTF-8", true);

PS : Not sure it's a good idea to modify response to put this kind of info as it will disturb performances of initial application .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top