Run massively scalable performance tests on web, mobile, and APIs

Request a Demo
Jul. 5th, 2017

How to Use Grafana to Monitor JMeter Non-GUI Results

Using Apache JMeter™ in non-GUI mode is a useful way to run your load tests, because it takes less machine resources and is quicker. But if you want to monitor these results, you have to use different tools.

 

In the previous article about JMeter monitoring in non-GUI mode, we covered three ways to easily verify real-time execution of JMeter performance scripts: with out-of-the-box logs, with Taurus and with BlazeMeter.

 

This time we are going to cover one more way, by using Grafana. This way requires installation of InfluxDB and Grafana. Grafana is an open-source platform for time series analytics, which allows you to create real-time graphs based on time series data. InfluxDB is the time series database which is used as a temporary metrics storage.

 

As both these tools are designed for time series data, combined they are a wonderful solution for keeping and visualizing real-time performance metrics. That’s why, even though the installation steps might make this way the most complicated one, we highly recommend it. Grafana and InfluxDB provide some unique benefits, which can be very valuable.
 

First of all, Grafana allows you to store performance reports as long as you want. Grafana reporting is also very beneficial for those who already use InfluxDB and Grafana for other needs. Grafana is a pretty common solution for overall application monitoring. Many companies use Grafana dashboards metrics with the Amazon Cloudwatch integration, which also makes it a commonly used solution.
 

In addition to that, Grafana allows you to customize your dashboards in any way you want. So we can definitely say that integrating JMeter with Grafana is a reasonable way to monitor your performance scripts - a bit complicated on the one hand but pretty beneficial on the other.

 

How to Integrate JMeter with Grafana

 

Install and Configure InfluxDB

 

First of all, we need a JMeter performance script to test. We can use the same performance script we created in the previous article, which is run against the http://blazedemo.com/ web application. Or, use your own.

 

As soon as we have the performance script in place, we need to take care of the InfluxDB and Grafana installation. In this article we are going to cover the brief steps of installation based on OS X as a target platform, but you can easily find installation steps for your system by using the appropriate links provided in each step.

 

First of all, we need to install InfluxDB as a permanent storage space for our performance metrics. Grafana is a scalable datastore for time series metrics. Installation steps for all supported platforms can be found through this link. Installation on the OS X machine is very straightforward and can be done in just a few steps, if brew is installed on your machine. In this case you just need to run these two commands:

 

> brew update
> brew install influxdb

 

At the end of installation you should see this:

 

jmeter results, non gui, influxdb, grafana

 

InfluxDB is installed and can be run by these two commands:

 

> ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
> launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist

 

To verify that InfluxDB is up and running, all you need to do is to open a terminal window and run this command:

 

> influx

 

If the installation was completed successfully and the database is up and running, you will see an InfluxDB command line interface. This can be used for interacting with the database.

 

By using the ‘SHOW DATABASES’ command, you can see the list of all existing InfluxDB dabasebases. If you have just installed InfluxDB you should see only one ‘_internal’ database, which is used for keeping different stats about database itself:

 

jmeter non-gui, test resuls, influx db, grafana

 

At this point we can create a new database to store our performance metrics. For that you need to be logged in influx command line interface and run this command:

 

> CREATE DATABASE jmeter

 

After that you should see your newly created database, by using the same ‘SHOW DATABASES’ command we used in the previous step:

 

jmeter non-gui results, monitor, influxdb, grafana

 

Once we have created a database for our metrics, we need to make a few changes to the InfluxDB configuration. Use this reference to find the location of the configuration file, based on your system. In the OS X system, the configuration file is located at this location:

 

> vim /usr/local/etc/influxdb.conf


In this configuration file you need to find, uncomment and edit the ‘[[graphite]]’ category appropriately:

 

[[graphite]]
  # Determines whether the graphite endpoint is enabled.
  enabled = true
  database = "jmeter"
  retention-policy = ""
  bind-address = ":2003"
  protocol = "tcp"
  consistency-level = "one"
  batch-size = 5000
  batch-pending = 10
  batch-timeout = "1s"
  udp-read-buffer = 0
  separator = "."

 

After that you need to restart InfluxDB by applying an edited configuration:

 

> influxd -config /usr/local/etc/influxdb.conf

 

To confirm the configuration was applied successfully, you should find this line during the InfluxDB startup:

 

analyze jmeter results with grafana

 

Congratulations! We have completed the first step of our long road to establish an integration of JMeter with Grafana monitoring. Now it’s time to push the metrics into the database we created.
 

Push Performance Metrics from JMeter to InfluxDB

 

To push performance metrics from JMeter to InfluxDB, we need to use the Backend Listener.  This listener enables writing metrics directly to the database.
 

Let’s add the Backend Listener to our performance script:

 

analyze jmeter kpis with Grafana

 

Configure the Backend Listener:

 

 

jmeter results analyzed in grafana

 

  • Backend Listener implementation - this is an implementation class that will be used as a listener for JMeter test metrics. The value for this parameter is based on the protocol we are going to use. If you remember, we used the graphite protocol configuration specified to the InfluxDB configuration. For this we need to use the ‘GraphiteBackendListenerClient’
  • Async Queue size - the queue value contains metrics for when they are processed asynchronously. It is better not to change this value from the default ‘5000’ value, unless have some specific performance issues.
  • graphiteMetricsSender - the implementation class that will be used as the metrics sender. Just use the default.
  • graphiteHost - the host where InfluxDB is located
  • graphitePort - the port we specified in the ‘graphite’ section of InfluxDB configuration file
  • rootMetricsPrefix - the basic prefix that will be used for all metrics stored in the database. Keep in mind that the metrics do not have a default separator. This is why it is better to use the ‘.’ symbol at the end of the prefix specified in this property
  • summaryOnly - use ‘true’ if you want to keep summary results only in the database and do not want to collect all the detailed metrics during test execution
  • samplersList - use this field if you want to send specific samplers only to the database. In our case, we want to send all samples, so we will leave this parameter blank
  • useRegexpForSamplersList - put ‘true’ if you want to specify a regexp in the ‘samplersList’ field to choose the samplers that should be sent to database
  • percentiles - is used to specify the metrics percentiles that should be send to database

 

Once the configuration is in place, we can run our test execution.
 

After the test execution is completed, we can check the InfluxDB and verify that our metrics were reported there successfully. To do so, open the InfluxDB command line interface again and use this command:

 

> influx
> USE jmeter
> SHOW MEASUREMENTS
> SELECT * FROM “jmeter.all.a.avg

 

We should find metrics with a timestamp and an appropriate value:

 

jmeter results in non-gui mode

 

Now that we see that all metrics were reported successfully from JMeter to InfluxDB, we are ready for out the last step - visualize reported metrics using Grafana.
 

Monitoring Performance Metrics in Grafana

 

First of all, let’s install Grafana on our local machine. Installation steps based on your system can be found through this link. For OS X the installation is very similar to the InfluxDB installations steps. Installation can also be performed via the brew package manager:

 

> brew install grafana

 

And another one to start the service:

 

> brew services start grafana


After that, Grafana should be available on http://localhost:3000. Use ‘admin’ as a default username and password to log in.

 

jmeter non-gui results on grafana


First of all, we need to specify the data source with our metrics. Click on “Add data source” on the welcome page:

 

grafana load testing results


On the next page put the appropriate configuration based on our previous steps, and click on the “Add” button to verify that Grafana can connect to InfluxDB:

 

performance test monitoring on grafana


Now we can create our first dashboard in Grafana. Open the Grafana menu by clicking on the top left button and go to Dashboards -> New:

 

grafana test results for jmeter

 

I would definitely recommend going over Grafana documentation to understand the main principles and to learn how to create detailed graphs for different needs. You can use this link as an intro step.

 

But to explain briefly, you can create different dashboards and specify multiple rows that represent time series metrics, in each dashboard. Grafana takes the data from InfluxDB which was collected there from JMeter. By clicking on the top of each row, you can choose which metric that row should represent.

 

load testing and analyzing results on grafana with influxdb

 

Grafana enables you to customize your metrics and graphs in any way you want. This  makes it very flexible for your needs. You can combine all the useful information into one dashboard and use it for real-time monitoring of your performance scripts.
 

In addition, since all metrics are stored on your server database, you can keep these metrics forever and create performance patterns analysis during your next test executions. Just add more graphs. This will ensure you’re on top of JMeter monitoring!

 

jmeter monitoring on grafana

 

Congratulations! You now know how to monitor JMeter non-GUI results with Grafana. To start testing and analyzing with BlazeMeter, just put your URL or JMX file in the box below and your test will start in minutes.
 

To learn JMeter, check out our free JMeter academy.

 

Click here to subscribe to our newsletter.

     
arrow Please enter a valid URL

Interested in writing for our Blog? Send us a pitch!