Apache JMeter with Streamlit for Machine Learning

Apache JMeter Streamlit Machine Learning I recently stumbled upon an open source project called Streamlit. Streamlit is a framework where you can build custom Machine Learning tools by focussing on data science rather than the user interface. You can spin up your app with the intuitive user interface and leverage Python modules at ease. In this blog post, I am going to present everything in detail about how I leveraged Streamlit for Apache JMeter and what are all the benefits, future plan, and more.

What is Streamlit?

Streamlit is an open-source Python library that makes it easy to build beautiful apps for machine learning.

It is simple, but powerful app model which helps you to build rich UI. You write the code, instantly you can see the output in the browser.

Use case of Streamlit

Below repository has the sample app demo, if you would like to see the real life use cases.

https://github.com/streamlit/demo-uber-nyc-pickups

Deep dream and Shaobo Guan’s Face-GAN explorer source will be available soon. You can star the Streamlit repo in here.

Apache JMeter with Streamlit for Machine Learning

By integrating Streamlit with Apache JMeter, you can build machine learning models to train to detect anomalies from your JMeter test results.

Please note that this project is just a beginning where you can execute and visualize the test results in interactive charts.

I am currently working on designing the machine learning model for performance testing metrics.

Demo

Prerequisites

You need the following stuffs to get started. I designed this app in my Windows 10 laptop, but it should work in other operating systems as well.

Please try to use the latest version as possible e.g. have JMeter 5.2.1 instead of JMeter 5.2. I prefer Anaconda to install Streamlit. You can read the instructions over here.

I assume that you already have a working knowledge on Apache JMeter. If not, you can check this link to get started.

Once all the software is installed and verified, add the JMETER_HOME environmental variable in your System pointing to the JMeter folder (containing JMeter sub-folders: bin, lib, docs etc.). This is a must to execute the JMeter test plan.

You can validate the environmental variable propagation via cmd > %JMETER_HOME% command.

Clone the repository

Now it is time to clone the Streamlit-JMeter repository. After cloning, navigate into the repository in the command prompt and run the below command. You could use the terminal which is available in VS Code or PyCharm as well. As I mentioned, I prefer VS Code.

python -m pip install -r .\requirements.txt

Above command will install the necessary modules for the app.

In the command prompt, enter the below command:

streamlit run app.py

In case of powershell, issue the below command

streamlit run .\app.py

This will open a new tab or launch the default browser with the URL http://localhost:8501

You could see the About page.

Execute JMeter Test Plan

To execute JMeter test plan, click on left sidebar widget and then click on Execute JMeter Test Plan radio button. This will bring up the page where you can select the JMeter test plan as shown below.

Execute

After selecting the JMX file, click on Run button to execute the JMeter test plan. This will execute your test plan in CLI mode and generates unique log file and place it in the bin folder.

Log file

At top right corner, you could see the progress of the app.

Status

To monitor the performance, go to the command prompt which displays the run time stats.

If you would like to stop the script execution, go to the command prompt and issue the CTRL + C shortcut.

Analyze

To analyze the test results, click on Analyze JMeter Test Results radio button which will bring up the page as shown below. Select the csv file to analyze which will display the metrics such as start time, end time, summary report etc.

To view the graphs, click on Show Graphs checkbox.

Analyze

All the graphs are interactive, on need basis you can generate variety of combinations by custom coding. Under the hood, graphs plotted using vega-lite.

Graphs - Apache JMeter with Streamlit for Machine Learning

Limitations

  • Supports only CSV results
  • By default, it fetches all the files from the JMETER_HOME folder.
  • Limited number of charts has been added, other type of charts can be added by custom coding.

Known Issues

  • Doesn’t execute if the JMeter file name which has space
  • Quick Navigation between Execute and Analyze may break the code, you may need to launch the app again.
  • Doesn’t display the JMeter test results runtime

What’s next?

  • This is just a inception version where I experimented the capabilities of streamlit. The next big thing is writing a training model to detect the anomalies and predict the point of failure which is work-in-progress.

Notes

  • I am not a professional developer nor a good open-source maintainer. My code may not have the standards, but it will do its job if everything is properly set.
Powering up Apache JMeter with Streamlit and opening the door for machine learning.

2 thoughts on “Apache JMeter with Streamlit for Machine Learning”

Leave a Comment

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

Learn Kubernetes and Get Certified in CKAD.SHOW ME HOW
+ +
Share via
Copy link