Dynatrace Backend Listener for JMeter

Couple months ago Dynatrace had released brand-new backend listener for JMeter which streams the performance stats from JMeter to Dynatrace. This backend listener sends the JMeter metrics to the Dynatrace environment via MINT. This blog post features about the Dynatrace Backend Listener for JMeter, how to integrate it, create dashboards and more.

Prerequisites

Before we get started with the integration of Dynatrace backend listener in JMeter, let us fulfill the prerequisites.

  1. Dynatrace account. It is free to sign up.
  2. Sample demo app which is already integrated with Dynatrace
  3. Apache JMeter (the latest version)
  4. Sample JMeter test plan to execute a simple load test against the demo app.

Step 1 – Download JAR for JMeter

Download the JMeter plugin from the Dynatrace OSS repo. Download the latest version from the Assets as shown below.

If you want to build it on your own, clone the repo https://github.com/dynatrace-oss/jmeter-dynatrace-plugin.git.

cd into the folder and run .\gradlew build in Powershell.

This will create build the jar for JMeter. Navigate to jmeter-dynatrace-plugin\build\libs.

Copy the jmeter-dynatrace-plugin-1.3-SNAPSHOT.jar to JMeter’s lib\ext folder.

Launch JMeter and open the test plan which you are going to execute. Right click on the Thread Group > Add > Listener > Backend Listener.

Select the implementation as com.dynatrace.jmeter.plugins.MintBackendListener as shown below.

Below are the default properties of Mint Backend Listener.

Step 2 – Configuring JMeter Backend Listener

To stream the JMeter performance stats to Dynatrace, the listener leverages Metric Ingest URL, API Token, test and transaction dimensions.

The URL would be your Dynatrace URL e.g. https://<environment_id>.live.dynatrace.com/api/v2/metrics/ingest

The Environment ID can be copied from the browser URL once you logged into your Dynatrace.

To generate a token, login into Dynatrace account, navigate to Settings > Integration > Dynatrace API. Under My Dynatrace API Tokens click on Generate token as shown below.

Enter a name for your token, select Ingest metrics under API v2 and then click on Generate button.

Click on Copy button and store the token in a secured place, because you cannot see it again in near future.

Dimensions can be specified using key=value pairs. There are two dimensions: test and transactions for test and test steps (samplers) related metrics respectively.

Following are the MINT metrics will be published during the test execution.

Below are the testDimensions will be generated when the test is running.

  1. jmeter.usermetrics.startedthreads: the number of started threads
  2. jmeter.usermetrics.finishedthreads: the number of finished threads
  3. jmeter.usermetrics.minactivethreads: the minimum number of active threads
  4. jmeter.usermetrics.maxactivethreads: the maximum number of active threads
  5. jmeter.usermetrics.meanactivethreads: the arithmetic mean of active threads

E.g.

c.d.j.p.MintMetricSender: addMetric(jmeter.usermetrics.minactivethreads,testname=Dynatrace-JMeter.jmx gauge,1.0 1609460965970)
c.d.j.p.MintMetricSender: addMetric(jmeter.usermetrics.maxactivethreads,testname=Dynatrace-JMeter.jmx gauge,1.0 1609460965971)
c.d.j.p.MintMetricSender: addMetric(jmeter.usermetrics.meanactivethreads,testname=Dynatrace-JMeter.jmx gauge,1.0 1609460965971)
c.d.j.p.MintMetricSender: addMetric(jmeter.usermetrics.startedthreads,testname=Dynatrace-JMeter.jmx gauge,1.0 1609460965971)
c.d.j.p.MintMetricSender: addMetric(jmeter.usermetrics.finishedthreads,testname=Dynatrace-JMeter.jmx gauge,1.0 1609460965971)

Below are the transactionDimensions.

  1. jmeter.usermetrics.transaction.mintime: the minimal elapsed time for requests within sliding window
  2. jmeter.usermetrics.transaction.maxtime: the maximal elapsed time for requests within sliding window
  3. jmeter.usermetrics.transaction.meantime: the arithmetic mean of the elapsed time
  4. jmeter.usermetrics.transaction.receivedbytes: the number of received bytes
  5. jmeter.usermetrics.transaction.sentbytes: the number of sent bytes
  6. jmeter.usermetrics.transaction.hits: the number of hits to the server
  7. jmeter.usermetrics.transaction.error: the number of failed requests
  8. jmeter.usermetrics.transaction.success: the number of successful requests
  9. jmeter.usermetrics.transaction.count: the total number of requests

E.g.

addMetric(jmeter.usermetrics.transaction.count,transaction=T00_HomePage,dt.entity.service=SERVICE-XXXXXXXXXXXXXXX gauge,1.0 1609460965969)
addMetric(jmeter.usermetrics.transaction.success,transaction=T00_HomePage,dt.entity.service=SERVICE-XXXXXXXXXXXXXXX gauge,1.0 1609460965969)
addMetric(jmeter.usermetrics.transaction.error,transaction=T00_HomePage,dt.entity.service=SERVICE-XXXXXXXXXXXXXXX gauge,0.0 1609460965969)
addMetric(jmeter.usermetrics.transaction.hits,transaction=T00_HomePage,dt.entity.service=SERVICE-XXXXXXXXXXXXXXXX gauge,1.0 1609460965969)
addMetric(jmeter.usermetrics.transaction.mintime,transaction=T00_HomePage,dt.entity.service=SERVICE-XXXXXXXXXXXXXXX gauge,26.0 1609460965969)

Dimensions are optional. But the metric and payload is required.

jmeter.usermetrics.transaction.count,transaction=T00_HomePagegauge,1.0 1609460965969

After adding all the values in the backend listener, this is how it looks. Instead of hard coding, all the values will be read from the test plan variables.

How to get the Service ID?

In Dynatrace, navigate to Application and services, click on the service name. In the browser URL, you can fetch the Service ID.

E.g. https://<environment_id>.live.dynatrace.com/#newservices/serviceOverview;id=<SERVICE-XXXXXXXXXXXXXXXX>;gtf=-2h;gf=all

Copy the service id including the string SERVICE- and 17 length string to JMeter.

Step 3 – Test Execution

Start your test in CLI mode. While the test is running, go to Dynatrace, click on Applications or Transactions and services make sure you are seeing the load test traffic in Dynatrace.

I am running a demo app in Flask at port 7000. If the integration between the demo app and Dynatrace is valid, you will see the traffic as shown below.

To view the JMeter metrics, go to Dashboard > Create Dashboard, enter a valid name and then click on Create.

Drag-and-drop the Custom Chart to the dashboard and then click on Configure custom chart.

Click on Try it out.

Start typing jmeter as shown below. Dynatrace will list out all the metrics available.

Enter jmeter.usermetrics.maxactivethreads to get the maximum active threads and then click on Add Metric if you would like to add more metrics, else click on Run query.

You can customize the graph and colors under the Settings.

Here is how it looks for Single Value visualization.

To pin the above chart, click on Pin to dashboard and enter the title and then click on Pin, then click on Open Dashboard.

Here is the dashboard view.

Here is my sample dashboard which I customized. Beautiful, isn’t it?

Final Words

JMeter backend listener for Dynatrace streams the performance stats straight to Dynatrace. It will be helpful to compare the head-to-head metrics between Dynatrace and JMeter. Often, I present both the metrics to the architects, but with this integration, I save time and effort by migrating JMeter metrics to my dashboard.

About the Author

1 thought on “Dynatrace Backend Listener for JMeter”

  1. Hi Naveen
    Hope you are doing Good
    Iam Integreate Jmeter with Dynatrace
    How to get the service id but iam not ablle to findout Please help me on that

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Hamster - Launch JMeter Recent Test Plans SwiftlyDownload for free
+
Share via
Copy link