%%
Last Updated:
- [[2021-02-20]]
%%
[[JMeter]] allows for the creation of a custom metric that can then also be visualized in the HTML reports.
## How to see a custom metric in JMeter results
### Save measurement into a variable
Use a [[JMeter BeanShell Sampler]] or [[Groovy]] sampler to save values to a variable.
### Add custom metric variable to JMeter properties
Add the variable used to the JMeter properties file: (either `user.properties` or `jmeter.properties`):
`sample_variables=QueueLength,DummyVariable`
This variable should then be tracked in your results file.
## Adding custom variable to HTML report
To add the variable to the [[JMeter/HTML report]], you'll need to add specifications for what to graph, including:
- the title of the graph
- the variable to be graphed on the Y axis
- the variable to be graphed on the X axis
- the granularity of the measurement
- the variable to be plotted
Here's an example:[^01]
```bash
# 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
```
Put this in the relevant JMeter properties file.
[^01]: [[Generating Custom Chart in JMeter - PerfTuned]]