JMeter: user variable to report - jmeter

I'm having next structure of TG in Jmeter:
So I have variable LB_LEVEL and 100 threads. It's value for every user may be different (from 1lv to 23lv e.g.)
I try to find a way to make some visual report with this variable, simply I have to show how users were casted to different levels.
It may be csv, or smh. Ideal table of my dream looks like this:
Googling still brings me some foam, so I need a small idea or kick to correct direction.
Thank you!

Add the next lines to user.properties file:
sample_variables=LB_LEVEL
jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_testGraph.title=LB LEVEL
jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=LB LEVEL
jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=LB_LEVEL
jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=LB_LEVEL:
sample_variables is a special property which saves custom variable(s) into .jtl results file
Restart JMeter to pick the properties up
Run your JMeter test in command-line non-GUI mode and generate the HTML Reporting Dash board as:
jmeter -n -t <test JMX file> -l <test log file> -e -o <Path to output folder>
Open <Path to output folder>/index.html file with your favourite browser - you will see plotted LB_LEVEL values along with other tables and charts.
If for some reason it doesn't fit your needs you can consider using Flexible File Writer to store the metrics of your choice into a file, in your case they would be grpThreads and variable#0

Related

how to stop jmeter from writing anything in the .csv results file

Straight and short, i want jmeter to stop writing any output in the .csv results file.
I've heard that preventing the creation of the file is not possible however we can set the results file configuration properties to decide what values to output so basically i went over all those properties, i did read them all and i set the ones that i could set to false to false, the ones that i could set to none to none and the ones that i could set to their default values to their default values, in theory the file shouldn't print anything and remain at 0kbs, however this is not the case the file still grows in size and it is printing a zero every line like these:
0
0
0
0
and this is how i have my properties in the user.properties file
jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.assertion_results_failure_message=false
jmeter.save.saveservice.assertion_results=none
jmeter.save.saveservice.data_type=false
jmeter.save.saveservice.label=false
jmeter.save.saveservice.response_code=false
jmeter.save.saveservice.response_data=false
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=false
jmeter.save.saveservice.successful=false
jmeter.save.saveservice.thread_name=false
jmeter.save.saveservice.time=false
jmeter.save.saveservice.subresults=false
jmeter.save.saveservice.assertions=false
jmeter.save.saveservice.latency=false
jmeter.save.saveservice.connect_time=false
jmeter.save.saveservice.samplerData=false
jmeter.save.saveservice.responseHeaders=false
jmeter.save.saveservice.requestHeaders=false
jmeter.save.saveservice.encoding=false
jmeter.save.saveservice.bytes=false
jmeter.save.saveservice.url=false
jmeter.save.saveservice.filename=false
jmeter.save.saveservice.hostname=false
jmeter.save.saveservice.thread_counts=false
jmeter.save.saveservice.sample_count=false
jmeter.save.saveservice.idle_time=false
jmeter.save.saveservice.timestamp_format=none
jmeter.save.saveservice.default_delimiter=,
jmeter.save.saveservice.print_field_names=false
jmeter.save.saveservice.xml_pi=
jmeter.save.saveservice.base_prefix=~/
jmeter.save.saveservice.autoflush=false
Where is that 0 coming from? is it impossible?
If you don't want the results file just don't provide its location, i.e. omit this -l bit when you launch JMeter test in command-line non-GUI mode:
jmeter -n -t test.jmx
The above command will trigger the test execution but no .jtl results file will be created.
Not sure why you want to create a .csv file when your not storing anything into it.
Maybe just don't give any file name here

Using time function in Summary Report listener filename

In JMeter (5.1.1) I have a summary report that I'm trying to save as a timestamped file. The filename value looks like the following:
D:\Load Tests\example.com\Results\${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
However, rather than create the file with the result of the __time() function e.g. 2019-07-22-10-24-03_summary.csv, it's actually generating a filename called ${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv.
I've tried creating a user-defined variable called timestamp with the value ${__time(yyyy-MM-dd-HH-mm-ss,)} and referencing it with ...\${timestamp}_summary.csv but this similarly results in $(timestamp)_summary.csv.
I saw a JMeter Archive post regarding a similar question to mine from 2006 where it's implied that listener filenames are resolved too early for functions and variables to be used, but I'm hoping that JMeter has been able to overcome this hurdle in the 13 years since then.
Is it possible to use variables for listener filenames in JMeter GUI and set them dynamically like the timestamp above?
If not, is there an alternative method of doing this using Groovy? Where would this be - in a setup thread JR223 sampler perhaps? I have tried this and seemingly managed to programatically change the filename, but no file was saved.
Update with answer:
I just needed to reverse the path delimiters from \ to /.
D:/Load Tests/example.com/Results/${__time(yyyy-MM-dd-HH-mm-ss,)}/summary.csv
I come across this issue and figure out that it works when you specify your path with the slash, instead of backlash.
For example:
D:\Load
Tests\example.com\Results\${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
Doesn't work. But:
./Load
Tests/example.com/Result/${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
Will work.
I usually don't write long answers, but you touch a bit of a sore point,
Listeners are classic example of Can't Live with You, Can't Live Without You
JMeter mindset is load testing (although can be used for functional tests)
Therefore, the moto/best practice is You shouldn't use it
Use CLI mode: jmeter -n -t test.jmx -l test.jtl
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them only during scripting phase to debug your scripts.
But...in the same document it suggest it for testing/debugging
Create a simple Test Plan containing the JSR223 Sampler and Tree View Listener. Code the script in the sampler script pane, and test it by running the test.
Basically/In the end, you need to save first jtl file using -l myresults.jtl
And then convert it to CSV using JMeterPluginsCMD, example:
JMeterPluginsCMD.bat --generate-csv test.csv --input-jtl results.jtl --plugin-type ResponseTimesOverTime
Or do it the JMeter way with creating a dashboard
jmeter -g <log file> -o <Path to output folder>
You should not be using any Listeners in your tests as it violates JMeter Best Practices
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
you should be running JMeter in non-GUI mode like:
jmeter -n -t test.jmx -l summary.jtl
If you want to amend the summary.jtl filename to include timestamp - you can use date and time commands combination like:
jmeter -n -t test.jmx -l %date:~-4%-%date:~4,2%-%date:~7,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%_summary.jtl
Demo:

JMeter - Can I set report granularity at the command line?

I have some JMeter tests, and they take different amounts of time. I'd like to change the granularity of the reports without having to change the reportgenerator.properties file. I read the documentation about generating reports, and I'm still not clear. Do I do it something like -Jreportgenerator.properties.overall_granularity=10000?
Can/How do I do this?
Actually, I found that the following worked for me in JMeter 3.2.....
jmeter.bat -Jjmeter.reportgenerator.overall_granularity=1000 -g testresults.jtl -o dashboard
This sets the granularity to 1 second for my report.
And another example,to give the report a granularity of 1 second and a different title e.g. My Report
jmeter.bat -Jjmeter.reportgenerator.overall_granularity=1000 -Jjmeter.reportgenerator.report_title="My Report" -g testresults.jtl
-o dashboard
First of all, here's a cite from the aforementioned file:
THIS FILE SHOULD NOT BE MODIFIED
This avoids having to re-apply the modifications when upgrading JMeter
Instead only user.properties should be modified:
1/ copy the property you want to modify to user.properties from here
2/ Change its value there
Then, -D option overrides system property for JVM, that should look like
-Dreportgenerator.properties.overall_granularity=10000
you may add it stright to the command line when starting JMeter with standard script provided.
As far as I know, usually for JVM running JMeter the genuine configuration properties are looking exactly like this (system properties), so application of -D option must work.
Here's the kind of a proof from official properties reference:
The properties present in jmeter.properties or
reportgenerator.properties should be set in the user.properties file.
These properties are only taken into account after restarting JMeter
as they are usually resolved when the class is loaded.
So that must be working, come back if not. :-)
UPDATE:
It turns out, the property name has been misspelled by topicstarter, the correct name is:
-Djmeter.reportgenerator.overall_granularity=10000
./jmeter.sh -Jjmeter.reportgenerator.overall_granularity=1000 -g /path/to/jtl/file -o /where/you/want/to/store/dashboard
This works perfectly in JMeter 4.0 and 5.0

How to write Jmeter Regex into a file after extraction

In my Jmeter test, I am able to use REGEX Extraction, After extraction I want to write the value of the REGEX variable into a file
I found a workaround as using beanshell as mentioned here https://stackoverflow.com/a/15159521/4556894
Is there any clean way of doing it, May be some inbuilt features, which I am not aware of
It is possible to write variable values into JMeter .jtl results file. There is a JMeter Property called sample_variables
Optional list of JMeter variable names whose values are to be saved in the result data files.
Use commas to separate the names.For example:
sample_variables=SESSION_ID,REFERENCE
So if you run JMeter in command-line non-GUI mode as follows:
jmeter -Jsample_variables=myVariable -n -t /path/to/your/testplan.jmx -l /path/to/testresults.jtl
You'll get the output like
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,bytes,grpThreads,allThreads,Latency,"myVariable"
1425978657207,368,HTTP Request,200,OK,Thread Group 1-1,text,true,1591,1,1,367,YOUR_VARIABLE_VALUE
In above example column names are given for reference, they are not included into csv results file by default. This behavior is controllable via jmeter.save.saveservice.print_field_names property, set it to "true" to get column names printed along with results data.
You can also set sample_variables property value in user.properties file which lives under /bin folder of your JMeter installation or uncomment it in jmeter.properties file (same location)
For more information on JMeter properties and ways of setting and/or overriding them refer to Apache JMeter Properties Customization Guide

Writing to a file named with variables in distributed JMeter testing

Okay I've been having an issue with writing results to folders in JMeter.
I have set 2 variables, one for the name of the test and one for the submit date. I want the reports to be written to the folder named with these two variables.
Here's the variables:
TestRun = "Name of test"
DateRun = $__{time(dd-MMM-yyyy HH.mm.ss)}
The path of the folder to be written to looks like this:
C:\Tests\TestEnvironment\Results\\${TestRun}${DateRun}\file.csv
When I run it on the master machine, it's fine. It saves to the correct file and folder path, and ends up looking something like this:
C:\Tests\TestEnvironment\Results\Test Run 1 - 08-May-2014 08.55.47\file.csv
However, when I run it on remote machines, it saves it literally as below:
C:\Tests\TestEnvironment\Results\${TestRun}${DateRun}\file.csv
So I end up with a folder named "${TestRun}${DateRun}"
Am I missing something blindingly obvious, or is this an actual JMeter issue?
Thanks!
As per JMeter help:
-G, --globalproperty <argument>=<value>
Define Global properties (sent to servers)
e.g. -Gport=123
or -Gglobal.properties
You need to use -G key so your variables could be distributed across remote clients.
so something like:
jmeter -r -n GTestRun=SomeName -GDateRun=SomeTime -t /path/to/your/plan
should help.
Alternatively you can create a .properties file and pass it to remote JMeter Engines via the same "-G" option.
I expect that if you want to use JMeter __time() function you'll need to wrap it with __eval, elsewise it will be treated as a string. Alternatively you can use operating system commands to retrieve current date and time.
See Apache JMeter Properties Customization Guide for more information on dealing with JMeter Properties.

Resources