Craft Powerful Performance Tests with Ease Loadium Script Builder
Dynatrace Integration With JMeter
Dynatrace Integration With JMeter
In this article we will learn how to integrate Jmeter with Dynatrace.
What is Dynatrace
Dynatrace is an APM solution that monitors Web, Mobile and Cloud-Based applications, infrastructure, network and critical processes, and also provides performance management of all technology layers used, from the selection of users on the website to the application code running on the main system, with real user monitoring.
Why Should We Use Dynatrace
While load testing tools provide sufficient information at the network level, sometimes it is desirable to analyze what is happening at the application level. With load testing tools such as Jmeter, we can have general information about the services, but we cannot observe the behavior of SQL queries under the services. For this reason, we cannot see in detail why the services are not working properly.
Thanks to APM tools such as Dynatrace, we can observe the behavior of the queries under the services in detail and see in which situations the bottleneck occurs. This is exactly what is made possible by APM tools such as Dynatrace when integrated with JMeter, which is the most popular load testing tool for analyzing and measuring the performance of a variety of services.
Custom Header Parameters
According to the dynatarece document, there are 6 parameters we need to use to filter our requests. For this, we have to add those parameters to our requests’ custom-header. We can use HTTP Header Manager for this. Let’s take a look at the values which are all configured under a custom-header called X-Dynatrace-Test.
Creating a Script with Header Parameters
With the following code, we can add all custom-headers to our requests instead of the adding one by one.
import org.apache.jmeter.protocol.http.control.Header;
def vu = ctx.getThreadGroup().getName() + "-" + ctx.getThreadNum();
def si = "JMeter" + org.apache.jmeter.util.JMeterUtils.getJMeterVersion();
def tsn = sampler.getName()
def ltn
def lsn
try {
lsn = (args.length > 0) ? args[0] : "No name for Test Plan" //To Configure Test Plan name, add ${__TestPlanName} in Parameters as first argument
ltn = vars.get("LoadTestName") ?: "No name for Load Test" //To Configure Load Test Name, add a variable `LoadTestName` and the value in Test Plan or User Defined Variables
dtcustom-headers = "SI="+ si + ";LSN="+ lsn + ";TSN=" + tsn + ";LTN=" + ltn + ";VU=" + vu + ";";
sampler.custom-headerManager.removeHeaderNamed('X-Dynatrace-Test')
sampler.custom-headerManager.add(new Header('X-Dynatrace-Test', dtcustom-headers))
}
catch(Exception e) {
log.info("Caught " + e) //Catching the exception
}
As you can see, custom-headers added automatically after I run the test.
Before we can perform the operations in this article, we need to install the Dynatrace Agent in our system. You can use the link for this.
After logging in to your dynatrace account, you must first deploy dynatrace where you want to monitor the traffic in order to track your traffic. Then, we go to the Services page under Applications & Microservices from the menu on the left of the homepage.
On this page, there are services whose traffic I can monitor. When I run the script I prepared with Jmeter and select the Requests executed in the background threads of ApacheJMeter.jar from the screen, I can see the general information about the relevant service. To monitor the traffic, we click on the View Requests option on the page that opens.
Don’t forget to set the time interval in the top right to the interval we want to observe the traffic. I set it to 5 minutes because I want to observe the traffic in the last 5 minutes.
The bars in the graph show the requests we made, and the line shows the response times of our requests. In the contributors field, we can see our services in the script we run.
As you can see, we were able to observe the load within 5 minutes from the time we ran the script.
To monitor service-based traffic, we can choose the service we want from the services under contributors.
If we want to have some more information about service, we should click on the three dots on the left and select what we need. Let’s say we want to compare today’s datas with yesterday’s datas. For this we should click to Comparison on the opening screen.
In this screen, we can see the information of the two selected data. such as response times of the selected service, errors received by the service, CPU usage and load on the server.
Thank you for reading this article. To stay updated with our latest posts, follow our blog and visit our social media accounts.