Site icon Vinsguru

JMeter – Real Time Results – InfluxDB & Grafana – Part 2 – Adding Custom Fields

I already have been using InfluxDB + Grafana for real time results of my JMeter test. You can find more details on the basic setup here.   In this article, Lets see how we can add some custom fields into the InfluxDB measurements for faster search which we might need in future.

Problem Statement:

In my organization we have a set of load generators for our performance testing. We use these machines for testing multiple projects / applications. Sometimes, I create multiple suites for component level testing of the application. You can check here to understand how I do this.

Our Backend Listener sends all the metrics into these measurements – end of the day – we are not sure of the application/project these metrics belong to.

 

It would be great if we could filter the metrics based on the application / project / suite / even Jenkins build #.

 

Solution:

Fortunately we do not have to come up with our own implementation to achieve this. The solution is very simple using existing JMeter’s Backend Listener itself.

jmeter.${project}.${suite}.${jenkins.build.number}.

 

But, It was NOT really what I wanted!!!

 

I do not want tons of measurements in InfluxDB which becomes very difficult to query / maintain.

Lets see how we could do better.

JMeter’s Graphite Inputs:

JMeter sends 2 types of metrics to InfluxDB in the below formats.

jmeter.testautomationguru.smoketest.121.Login.a.avg 135

status could be ok for pass, ko for fail, a for all

metric could be min, max, avg, pct90, pct 95 etc

page could be sampler name for sampler level details or all for aggregate info.

When InfluxDB receives data like this, If It is unable to locate template, It will create the measurement with the name if it is not present already & logs the value against the current time stamp in the measurement.

 

jmeter.testautomationguru.smoketest.121.test.meanAT 10

This is same like above. page & status are missing here & replaced by ‘test‘.

 

Templates for Graphite Inputs:

By using a template for the graphite inputs, we can avoid creating multiple measurements.

More information on Graphite Input template is here.

 

That is, the template for the Response time graphite input “jmeter.testautomationguru.smoketest.121.Login.a.avg” would be “measurement.project.suite.build.page.status.metric

 

We need to log thread/users metrics in different measurement as it can not be part of sampler level metrics.  As JMeter sends 2 metrics in slightly different formats, Lets catch them separately.

 

By using regex format, if the input is in certain format, We can instruct InfluxDB to use specific template.

 

For this input – “jmeter.testautomationguru.smoketest.121.test.meanAT“, project, suite, build number can be anything. But It will be followed by ‘test‘ for sure.

So, all the user metrics can be captured by this input format – “jmeter...*.test

Update the templates accordingly in InfluxDB config file and restart InfluxDB to fetch update the configurations.

 

Run the JMeter test now & see.  [Please note that InfluxDB will use the template only for new inputs. Existing measurements can not be altered]

We could see only 2 measurements now. 1 for response time & other one for user metrics.

If I query the measurement, I get my project/application,suite, build info, page, status etc as different columns.

 

“jmeter.test” is for thread/user metrics which has similar information.

 

This is much better!!

 

 

Grafana Templates:

As we log project, suite, Jenkins build #, metric etc as measurement tags/columns, We can use Grafana templates to filter / repeat entire rows.

Check this video on creating template variables & using in the query for filtering.

 

Repeating Panel For Page:

We can make the entire panel repeat for each variable/page. Check this video.

 

Summary:

As we have seen we should be able to add some custom data in InfluxDB for faster search using Graphite Input templates & Grafana template variables.

This article only covers the JMeter performance test results. You also might be very interested in collecting application server performance metrics + JVM metrics. Check below articles of TestautomationGuru.

Happy Testing & Subscribe 🙂

 

 

Share This:

Exit mobile version