Since JMeter 5.0 testers have an option of generating additional charts as a part of the report dashboard. Did you know about that?

Thanks to this you can visualize a specified variable over time of a test like below:

 

custom chart jmeter

Let’s check how to do it.

 

What can I visualize?

As already mentioned you need to have a variable that will be charted over the time of the tests e.g.:

  • a special metric that you compute during a test,
  • a metric that is returned from the server as:
    • result of query checking a count on a table,
    • or a queue length,
    • processing times that some frameworks return in headers etc.
  • value of a ‘Counter’ component
  • others

 

OK, let’s say I have a metric that should be put on a plot, what now?

Configuration on the JMeter side

    • First of all you need to store the metric in a JMeter variable (that means that if needed it needs to be extracted from a response using one of the extractors).

 

  • Name of the variable that you want to have on a graph needs to be specified as a so-called sample variable.

To do that just add a line like below, containing your variable to the JMeter’s properties file, e.g. user.properties or jmeter.properties. In my case I’ve added multiple sample variables:

    sample_variables=QueueLength,DummyVariable

Very important thing! It needs to be done before the test, so the values of the variable are written to the test results file.

  • Now you need to provide a simple definition of your chart containing:
    • name of the chart (QueueLengthGraph in the example below)
    • title of the chart
    • description of the X and Y axis
    • granularity (can be left as defined globally for the dashboard)
    • and finally name of the variable that should be plotted

 

# Queue length graph
jmeter.reportgenerator.graph.custom_QueueLengthGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_QueueLengthGraph.title=Number of messages in the queue over time
jmeter.reportgenerator.graph.custom_QueueLengthGraph.property.set_Y_Axis=Queue length
jmeter.reportgenerator.graph.custom_QueueLengthGraph.property.set_X_Axis=Test duration
jmeter.reportgenerator.graph.custom_QueueLengthGraph.property.set_granularity=${jmeter.reportgenerator.overall_granularity}
jmeter.reportgenerator.graph.custom_QueueLengthGraph.property.set_Sample_Variable_Name=QueueLength

Again, you can put it in one of the JMeter’s properties files e.g user.properties, reportgenerator.properties or other.

Final result

Now it’s time to generate the reporting dashboard. When viewing it in a browser just go to ‘Custom Graphs’ and you should be able to see your charts available there:

 

JMeter dashboard

 

Just select them and voila, you have have a plot for your own variable:

queue length chart