The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions. Note: influxd and grafana-server should be running always to push the JMeter data to InfluxDB and to access Grafana portal. Mac OS: Execute below commands; brew install grafana; brew services.
The first step is to identify the location of your JMeter. On Linux and Windows, it will probably the folder that you extracted JMeter. On Mac, if you installed JMeter using brew, you can use where jmeter to find out (it will probably be /usr/local/bin/jmeter). Then, to run JMeter in a NONGUI fashion, you can run the following command. Brew install ansible brew install terraform brew install jmeter You can just run them from your own machine. The full codebase is available on Github at RisingStack/distributed-loadtests-jmeter for your convenience. Why do we use Jmeter for distributed load testing? Jmeter: 18: Installs on Request (30 days) jmeter: 18: Build Errors (30 days) jmeter: 0: Installs (90 days) jmeter: 55: Installs on Request (90 days) jmeter: 55: Installs (365 days) jmeter: 349: Installs on Request (365 days) jmeter: 349.
As we all know that Most of the Companies are investing in best resources instead of licensed tools and moving towards open source technologies, We as a Performance engineers also has to adopt and utilize open source tools and technologies.
It is quite difficult to store JMeter test results for longer duration and to monitor JMeter test in non-gui mode. One of the solution is Grafana and InfluxDB.
In this article, I will explain step by step, how to install and configure Grafana and InfluxDB with JMeter in MAC and Windows OS.
InfluxDB Setup with JMeter
Windows OS
- First we have to download InfluxDB using following URL Download InfluxDB
- Unzip the downloaded file. You will see the folder structure like below
3. Open influxdb.conf file and scroll down till graphite section. You will find like below
4. Uncomment few configurations highlighted in below screenshot and change the value of enabled tag to true
5. Execute influxd exe from downloaded folder. This is to start the InfluxDB service.
6. Execute influx exe from downloaded folder to connect to Influx DB and create a database schema
7. Execute below commands to create a new database schema
- create database jmeter_demo; (jmeter_demo is the database schema name)
- show databases;
8. Next step is to add a backend listener in JMeter to send test stats to InfluxDB during execution. Do the configuration same as below screenshot. (Here 8086 is default port used by InfluxDB for web access)
- influxdbURL --> It should be the URL where InfluxDB is hosted followed by database name.
- application --> Mention any name to identify multiple applications test results.
- measurement --> Here jmeter is the table name where all the test stats will be written.
- samplersRegex --> .* will write all the transaction data into InfluxDB.
Make sure you are selecting InfluxDB backend listener client in Dropdown as below:
9. Now JMeter is successfully configured to send data stats to InfluxDB.
- To validate stats in Influx DB, Run a JMeter test and open influx exe application from downloaded folder
Execute following commands
- use jmeter_demo (Here Jmeter_demo is the database name which we created in step 7).
- select * from jmeter; (Here jmeter is a table name)
- you will be able to see the data in InfluxDB like below
MAC OS
It is quite easy to install InfluxDB and Grafana in MAC if you have Homebrew installed in your system. if not, Download Brew.
- Execute below commands to download InfluxDB
- brew update
- brew install influxdb
2. Run below commands after successful installation of InfluxDB
- ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
- launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
3. To Verify that InfluxDB is running or not, Execute below commands in terminal
- Influx
- SHOW DATABASES
- Create database jmeter_demo
4. Make few changes in the InfluxDB configuration file. File Path --> /usr/local/etc
- influxd config
- Refer step 4 in windows configuration as it is same.
5. Restart Influx DB
- brew services restart influxdb
6. Refer step 8 and 9 from windows installation to add a backend listener in Jmeter.
-----------------------------------------
Now as the data is reaching to InfluxDB successfully, Next step is to download Grafana and setup dashboard.
Download Grafana
Brew Jmeter Plugin Manager
Windows OS:
- Download Grafana
- Unzip the downloaded file, go to bin folder and run the grafana-server exe. It will start the grafana server and then you can setup InfluxDB in it.
Note: influxd and grafana-server should be running always to push the JMeter data to InfluxDB and to access Grafana portal.
Mac OS:
- Execute below commands
- brew install grafana
- brew services start grafana
----------------------------------
Setup Grafana and Dashboards
- To access Grafana, use http://localhost:3000/ (Grafana by default use 3000 port).
- login in Grafana using admin/admin as username and password.
- It will ask for password change, You can use the same admin as password.
- Next step is to add InfluxDB data source in Grafana.
- click on add data source.
- select InfluxDB and enter all the details as per below screenshot and click save. Make Sure you are giving 'Jmeter' in Name textBox as below reference dashboard is using datasource called 'Jmeter'.
7. Now InfluxDB is connected to Grafana, Next step is to create a dashboard to view test stats in graphical view.
- Go to dashboard home.
- Click on new dashboard. Here you can add multiple panels like graphs, tables etc..
- Click on graph then click on edit in panel title in the chart heading.
- Now you can write a query to fetch the required data from InfluxDB like below (Here jmeter represents table name and field(avg) represents average transaction response time).
Grafana Dashboard for JMeter test
I have created a dashboard to monitor JMeter test results. You can import it using following steps.
- Click on Dashboard --> Manage --> Import
- Download Dashboard JSON from following Git repository and click load.
- Make sure Datasource name is set to 'Jmeter' and save.
Brew Jmeter Gui
I hope you will find this article helpful. You can reach out to me if you face any issues while configuring Grafana.