Skip to content

Instantly share code, notes, and snippets.

@adrianmo
Last active March 12, 2020 05:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianmo/19ea0a1995228b2704b85ca5f0fde8b8 to your computer and use it in GitHub Desktop.
Save adrianmo/19ea0a1995228b2704b85ca5f0fde8b8 to your computer and use it in GitHub Desktop.
AzureBackendListener

Send your JMeter test results to Application Insights

This blog post will explain how to use the recently published Azure Backend Listener for JMeter to send your test result metrics to your Application Insights instance.

With the release of JMeter 3.2, the Apache team introduced a new BackendListener interface that allowed developers to build their own listeners and asynchronously push test result metrics to a backend of their choice.

This Application Insights integration leverages the JMeter Backend Listener interface by implementing a AzureBackendListenerClient. This implementation makes use of the telemetry client available in the Application Insights SDK for Java to send metrics to Azure.

Step-by-step with the Azure Backend Listener

We will go step-by-step on how to push your test results metrics to Application Insights. We will cover the process from a UI standpoint, but it can also be done via the command line.

Create an Application Insights instance

First, we will create an Application Insights instance from the portal and take note of the Instrumentation Key which we will use later on to tell the backend listener where to push the metrics.

Install Java

JMeter is a Java application, therefore the Java Virtual Machine must be installed prior to installing JMeter. You can check if Java is already installed in your system by opening a command line console and typing java -version.

C:\Users\admoreno> java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

If you get an output like the one above, Java is already present and you can proceed with JMeter installation. Otherwise, if you get a message like 'java' is not recognized..., you can download and install the latest Java SE Runtime Environment 8 for your system from Oracle's site.

Install JMeter

Now you can download the latest Apache JMeter binaries from the official site and uncompress it to a location of your choice.

Navigate to the JMeter directory and make sure JMeter is able to start. To run JMeter, browse to the bin/ directory and run jmeter.bat or jmeter.sh depending on if you are in Windows or Linux respectively. You should see the JMeter's UI.

JMeter UI

Install the plugin

Go to the GitHub releases for the Azure backend listener and download the JAR file for the latest release. The required JAR file will have the jmeter.backendlistener.azure-X.Y.Z.jar format.

Move the JAR file to the JMeter directory, inside the lib/ext/ directories. Your ext directory should look something like this.

libext directory

Close JMeter if it was running, and open it again to reload the installed plugins.

Configure the plugin

If you have an existing JMeter test plan file, you can go ahead and load it. Otherwise, you can download a simple test plan to try the plugin. This test plan will send 100 HTTP requests to http://bing.com from 10 threads across approximately 60 seconds, making a total of 1.000 requests.

Once loaded, JMeter should look like this.

simple.jmx

To make JMeter send test result metrics to your Azure Application Insights, in your Test Pan, right click on Thread Group > Add > Listener > Backend Listener, and choose io.github.adrianmo.jmeter.backendlistener.azure.AzureBackendClient from the Backend Listener implementation dropdown list.

Then, in the Parameters table, configure the following attributes.

Attribute Description Required
instrumentationKey The Instrumentation Key of your Application Insights instance Yes
testName Name of the test. This value is used to differentiate metrics across test runs or plans in Application Insights and allow you to filter them. Yes

plugin configuration

In this example, we have set the testName to simple-test-1.

Run your test plan

Once the configuration is in place, we can run our test plan. Click on the play/start button to start the test plan. As soon as it starts, the Azure Backend Listener will start pushing metrics which will be collected in your Application Insights instance, under the requests dimension and with the name simple-test-1.

Check the JMeter logs to make sure no error is thrown.

test run logs

Visualize test result metrics

After approximately one minute, the test will finish and your metrics should available in Application Insights. If they are not available, give it a few more minutes to become available. In the Azure portal, go to your Application Insights instance and go to Monitoring > Logs. Double click on the requests dimension to browse the metrics sent by JMeter. Make sure to also check the additional metrics available inside the customDimensions.

metrics

You can also create custom charts to visualize your metrics. For example, the following KQL query depicts the requests' duration during the test run. Make sure to adjust the time range to include your metrics.

requests
| where name == 'simple-test-1'
| summarize duration = avg(duration) by bin(timestamp, 1s)
| render timechart

test duration timechart

Feedback and contributions

If you have experienced any issues during the setup or usage of the plugin, or have any ideas for future enhancements, please let us know in the project's GitHub issues section. We also encourage direct contributions to the project by forking and making pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment