Postman Alternatives for Api Testing
Real Time Monitoring with JMeter InfluxDB Integration
Real Time Monitoring with JMeter InfluxDB Integration
There are lots of reasons why JMeter is one of the most popular performance testing tools in the market. And one of the biggest reasons is its reporting ability. Even though JMeter provides proper test results for your performance testing sessions, there are some problems as well. When you run your test in NON-GUI mode, you will need to wait until the test is complete to see the results. During long running sessions, seeing results immediately could be really crucial. Also, by applying some integrations -that will be shown below- you will have some sort of APM tool on your local system. To achieve this, you can think about integrating your JMeter script with JMeter InfluxDB and Grafana.
What is InfluxDB?
InfluxDB is a time-series database built for high-performance handling of time-stamped data. JMeter offers a backend listener named InfluxdbBackendListenerClient to write the data to InfluxDB. It is written in Go and optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics and real-time analytics.
What is Grafana?
By using Grafana, you can transform your data into interactive visuals. It provides charts, graphs, and alerts for the web when connected to supported data sources.
Requirements
1- JMeter, as the most essential one
2- InfluxDB, which can be downloaded via this link
3- Grafana, which can be downloaded via this link
Setup InfluxDB
Unzip your downloaded file for InfluxDB. Then open the file named influxdb.conf and configure it as follows:
As a database storage folder, you can create a seperate folder in your zip file location.
To start your InfluxDB session, navigate to the bin folder and double-click influxd.exe. After that, we need to create a database to collect our results. To do this, double-click influx.exe. You will see that a new command line/terminal screen is opened.
Type these commands to your console screen one by one:
CREATE DATABASE jmeter
SHOW DATABASES
Now you should be able to see a database named “jmeter”. In terms of InfluxDB connection, we are all set!
Configure your JMeter Script
To try your InfluxDB connection, you can open one of your existing test scripts as well. For example, I will be using my script that contains only one request to fetch the main page of google.com.
Right click on your Thread Group and add an InfluxDB Backend Listener by following this path: Add -> Listener -> Backend Listener
Choose your Backend Listener implementation according to the image above. Then rename it as “InfluxDB Backend Listener”. Now let’s dive into the details of some parameters.
influxdbUrl: Your url address for the created InfluxDB instance. You can find it on influx.exe console output.
summaryOnly: When defined as true, you will be seeing only the summary results of your database.
testTitle: You can give your test a name by this parameter.
Setup Grafana
Download Grafana from the link above. Unzip your files and then locate the /conf/sample.ini file and copy it to /conf/custom.ini. Default port for Grafana should be 3000. Edit custom.ini by uncommenting http_port and modifying the port.
After that process, we are ready to start our Grafana instance. navigate to /bin directory and run grafana-server.exe. You should be able to see a console application for Grafana now. Try going to http://localhost:3000/ from your browser. If you are able to see the screen below, you made it!
You can log in to Grafana interface with admin/admin credentials. After this step, you will see a dashboard screen.
Now we need to add a data source to fetch data from our InfluxDB instance. Simply click “Add data source” button and choose InfluxDB. Then configure your URL as “http://localhost:8086/” then define your Database as “jmeter” and minInterval time as 5s. Don’t forget to give your data source a name as well. After that, click “Save & Test”.
Now we need to choose a dashboard template. Even though you can create your own dashboard, we are going to use a template since we are trying just to see how Grafana works.
Click “+” button in the top left corner and click “Import Dashboard”. Define id as “5496” and click “Load”. Then you will see an “Import” screen. Configure the variables as below:
DB Name: InfluxDB
Folder: General
Measurement name: jmeter
Backend send interval: 5
Then click the “Import” button. You should be seeing an empty report page now. If this is the case, congrats! We can run our test now.
Go back to JMeter and change your Thread properties as above. Then start your test. After the first 5 seconds, you should be able to see live metrics on your Grafana report page.
The values on Grafana should be updating themselves every 5 seconds. If you are not able to see anything, try checking your Grafana data source connection and dashboard setup.
And that’s it. With InfluxDB and Grafana integrations on JMeter, you can track lots of details about the performance of your system.
Enjoy load testing with Loadium 🙂