JMeter

JMeter Dashboard – Grafana/InfluxDB using Docker

In the world of performance testing, there is no doubt, that JMeter is most powerful and widely used open source tool but lots of features are still not available in JMeter. One of them is analyzing performance test during execution . We always run JMeter scripts in Non GUI Mode to avoid memory issue but we get little or poor metrics in non GUI mode(Command prompt) ,Also there is no feature in JMeter for online reporting/Dashboard.

one of solution is to use Grafana and InfluxDB.

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.

you can find many articles to setup/install the Grafana/InfluxDB with JMeter but its a time taking to setup and use.

This article will show you that how to build a comprehensive lightweight performance monitoring solution from scratch, by using open source tools Docker .

These tools can provide you with outstanding monitoring and analysis abilities of your performance scripts. There are many options to install both of these tools separately or together, but the most efficient and easy is by using the Docker technology which save time. As soon as you have built the docker file that contains all the tools integrated together in the right way, it takes just a few minutes to spin up these tools anywhere and by anybody

Prerequisites

There are some prerequisites.In order to use the prepared docker file, you need to have the following installed:

  • Docker – to spin up the containers with InfluxDB and Grafana. Installation steps here.
  • Docker Compose – to integrate the InfluxDB and Grafana containers together and have just one script to rule them all. Installation steps here.

Setup

If you have docker and docker compose installed, then to setup the performance tests monitoring environment by using Grafana/InfluxDB you just need to proceed with a few simple steps:

you would get a “GrafanaInfluxDocker” folder at your location

This image has an empty alt attribute; its file name is image-1.png

Note:If you are using window machine then you need to change the end of line character to Unix(LF) . Just right at bottom and select Unix(LF) for each Dockerfile and entrypoint.sh files.

  • Step 4: Now perform cd to “GrafanaInfluxDocker ” and Run the command: > docker-compose up
  • Step 5: After few minutes. If you see a similar output then you are good:

That’s basically it! From this moment you have these Grafana and InfluxDB containers running locally on your machine:

 If you open http://localhost:3000 after the installation you should see your Grafana:

You can login using the default user ‘admin’ and ‘admin’ password (yes, security is not the highest priority in this article but you can change the credentials later). Also, if you go to the Grafana data sources configuration (Left top menu button -> Data Sources) you will see that the installed Grafana already has an in-built configuration with an InfluxDB instance that we are running in a separate docker container.

To be make sure that the integration works correctly, you can click on the ‘InfluxDB’ data source, scroll down to the end of the page and click on ‘Save and Test’. If you got ‘Data source is working’ then your lightweight monitoring environment is ready and verified!

Running the Containers

 As we showed before, in order to run the containers using docker compose, you need to run this command from the main folder where the ‘docker-compose.yml’ is located:

docker-compose up

This command will spin up Grafana and InfluxDB integrated together. Using this command, the containers will be run in the console in a way that if you close the console, the containers will be stopped. Sometimes, it is handy to run containers in the background so you can safely close your console and containers will still continue to run. To run the docker compose in background mode, you need to pass the additional argument ‘-d’:

docker-compose up -d

To stop the containers you can run the command:

docker-compose down

How to Run InfluxDB Queries

In order to run InfluxDB queries, you need to login inside the InfluxDB docker container. First, you need to get the list of all docker containers running. Use this specified command and find the container id related to the InfluxDB container (it should have the ‘influxdb’ string inside the container name): 

docker ps

Next, we are going to use the command that allows running a specified command inside the container. The last two values are arguments that represent the ID of the container and the command that will be run inside the container with the specified ID: 

docker exec -it [YOUR_INFLUXDB_CONTAINER_ID] influx

If everything is right, you should see the InfluxDB command line client that allows you to execute InfluxDB requests:

or You can use Chronograf and install which is the Complete Interface for the InfluxData Platform.


after adding a connection and for successfully added :

Got Explore Tab and there you can perform all DB queries:

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:

Now do the following setting in Backend Listener

  • Select the “org.apache.jmeter.visualizers.backend.influxdbBackendListenerClient” from the Backend Listener implementation drop down.
  • Change value of “influxdbUrl” ,provide host name or IP of machine on which you running the influxDB with Port.
  • Provide the name(db=jmeter) of the InfluxDB and replace it with “Jmeter”.
  • Change the application name and Test name as per your project.

Note : Do not change the measurement parameter value “jmeter”

How to setup Dashboard in Grafana

you can create your custom dashboard in grafana or you download and import the dashboard in grafana. You can download from here

you can import the Json file of the downloaded dashboard:

Click the Upload .json File button and browse the file:

Change the name of the dashboard and select the “InfluxDB” from drop down.

Now Run the JMeter Scripts and you would see the below metrics/graphs on grafana dashboard :

Note : If you don’t wanna run by using docker compose by using above approach ,you can separately run the individuals images. you can find grafana docker image from here and influxDB from here.

References:

https://jmeter.apache.org/usermanual/realtime-results.html

https://grafana.com/grafana

https://docs.influxdata.com/influxdb/v1.7/

Categories: JMeter, Out of Box

Tagged as:

1 reply »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s