JMeter Auto Correlation

After recording a Performance test in Apache JMeter, the recorded test is not immediately able to maintain the same session. Certain dynamic values change every time you make a request: the session ID, CSRF tokens, timestamps, and so on. Before the automated test can run, you must identify these dynamic values in the HTTP requests and responses, and replace them with variables. This manual process is called correlation.

Correlation is not the same as parameterization where hard-coded values are replaced by test data, because test data is from a different source. Correlation means extracting values from a previous response and passing them as arguments to the next request. Correlation is important in Performance testing because without it, generally, tests won't run at all or not as intended.

You as Tester typically use regular expressions or other extractors to extract values from responses; you store extracted values in variables and insert those variables in subsequent requests. This complex manual task takes up a lot of test creation time. BlazeMeter offers a JMeter plugin to assist you with correlation by doing repetitive tasks automatically.


Use the Auto Correlation Recorder Plugin

The BlazeMeter Auto Correlation Recorder is an open-source JMeter plugin that provides automatic correlation for JMeter tests. The plugin accelerates the test creation process, eliminates much of the complexity of correlation, and saves time. The plugin is built on top of the old BlazeMeter Correlation Plugin.

The recording process is the same as recording with the Apache JMeter Proxy Recorder, see the Apache documentation for details.

The plugin adds the following functionality to JMeter:

  • If a JMeter test plan replay has errors, the plugin suggests correlations to fix them.

  • The plugin opens an Automatic Correlation Wizard where you can choose which suggestions you want to apply. To provide context, the wizard lists attribute names and values from the response, when they were used, and where they were obtained from.

  • From your selections, the plugin creates templates of correlation rules.

  • The plugin lets you save and load your correlation rule templates files.




Types of Correlation Templates

  • Buit-in templates - Are free to use.

  • Enterprise templates - Require you to have an account that is not free.

  • Workspace templates - Can be edited and exported. They are also shared with anyone invited to your account.

Note: Any template that comes from BlazeMeter can't be edited or exported. We are not sharing the specifics of the Templates with anyone outside BlazeMeter, and it would be considered a breach of contract to attempt to do so.


Store Correlation Rule Templates

A BlazeMeter repository stores and shares correlation rule templates across your account. A correlation rule template contains one or more correlation rules files. To add templates, export them from JMeter's correlation recorder plugin in JSON format and click Upload.

To see which correlation rules you have stored in your BlazeMeter workspace, go to Settings, Workspace, Correlation Rules. Browse your Correlation Rule templates to see their names and versions.

Note: Some rules are built-in and available system-wide, while others are available for Enterprise Users Only.

Your own rules are available in your workspace only. You have access to all built-in rule templates that are part of your plan, and to all user rule templates that you have created in the specific workspace, including all detection files and correlation files that you have uploaded yourself.


Create a Correlation Template

Follow these steps:

  1. In JMeter, use the Correlation Recorder plugin to create your Correlation Template.

  2. In your JMeter installation folder, navigate to your local correlation-template folder.

  3. Locate the Template JSON file that you want to upload.

    Tip: If you want to edit Name, Version, and Description, edit the JSON file in a text editor now.

  4. In BlazeMeter, go to Settings, Workspace, Correlation Rule Templates.

You can find the new template in your list of templates.

To remove a template, click the delete button in the Actions column of the rule template.


Version Control and Test History

Version Control and test history for correlations is designed to enhance your testing workflow and reduce debugging time.

You can:

  • Undo changes and restore your test plan to the original state

  • View detailed history of your test plan, including all actions, steps, and versions

  • Select and restore the version of your test plan that you need


Restore a previous version of a test plan

Follow these steps:

  1. In your Test Plan, go to bzm - Correlation Recorder.

  2. Navigate to the Correlation tab, and click History.

    A History Manager window opens.

  3. Check the box next to the version of the test plan that you want to revert to.

  4. Click Restore.


JSON Correlation Rules

Important: This feature is available for manual correlation rules and is not available for autocorrelation. Integrating JSON support into the automatic generation feature is not part of this feature.

JSON was added as a configurable element in the correlation rules. Instead of creating complex regular expressions, you can now create JSON-type correlation rules and save and use templates with JSON rules.

Create a JSON-type correlation rule

Follow these steps:

  1. In JMeter, bzm-Correlation Recorder, click the Correlation tab.

  2. Click Add.

  3. For Correlation Extractor and Correlation Replacement drop-down lists, select the JSON rule type and fill out the JSON path expression.

  4. Enable Legacy Correlation mode. This will allow you to record, using the current rules.

    Note: If you already have a template and want to run an analysis of a particular flow, do not check the Legacy Correlation checkbox. Then, in the pop-up window, select Existing Correlation Templates.

  5. Click Start to record your flow.

  6. A pop-up window shows. Click Yes to confirm that the legacy mode is enabled.

After you stop the recording, click Recording Controller in the left menu to see details. You can see the JSON Path extractor there. It contains the JSON path expression that you’ve set.

Related Materials