Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Practical Advanced JMeter Workflows for Performance Testing and Metrics Integration

Tech 2

Connecting to MySQL Database

First, obtain the official MySQL JDBC driver (Connector/J):

  1. Navigate to the MySQL official site, go to Downloads > Community > MySQL Connnectors > Connector/J
  2. Select the Platform Independent distribution, download the archive when prompted to sign up by selecting "No thanks, just start my download"
  3. Extract the JAR file from the downloaded archive, add it to your JMeter test plan via the "Add directory or jar to classpath" section at the bottom of the Test Plan root element
  4. Add a JDBC Connection Configuration element to your test plan, set the JDBC URL to jdbc:mysql://localhost:3306/your_target_db (replace your_target_db with your actual database name), and assign a unique connection pool name to reference in subsequent JDBC request samplers.

Regular Expression Extractor Setup

Add a Regular Expression Extractor as a child of the sampler whose response you need to parse. Configure a reference name to store the extracted value, define the regex pattern to match your target content, set the template to specify which group to extract, and set the match number to pick the correct occurrence of the matched value. Use a Debug Sampler to validate extracted values during test development.

CSV Parameterization Configuration

Add a CSV Data Set Config element to your test plan, specify the full path to your CSV parameter file, define comma-separated variable names that map to columns in the CSV file, set the file delimiter matching your CSV format, and configure read behavior (recycle on end of file, stop thread on end of file) to align with your test use case. Reference the configured variables in samplers using the ${variable_name} syntax.

JMeter Plugin Installation

You can install community plugins using two methods:

  1. Manual installation: Download the plugin JAR file from the official JMeter Plugins portal, move the file to the lib/ext directory of your JMeter installation, then restart JMeter to load the plugin
  2. Plugin Manager installation: Open JMeter, navigate to Options > JMeter Plugins Manager, search for required plugins such as 3 Basic Graphs and Custom Thread Groups, select the plugins you need and click Apply Changes to install automatically.

InfluxDB 1.x Installation and Initial Setup

Download the appropriate InfluxDB 1.x binary for your operating system from the official InfluxData download portal. For macOS x86 systems, you can fetch and extract the archive directly via command line:

wget https://download.influxdata.com/influxdb/releases/influxdb-1.11.8-darwin-amd64.tar.gz
tar -xzf influxdb-1.11.8-darwin-amd64.tar.gz
cd influxdb-1.11.8-darwin-amd64

Run the following sequence to prepare the database for JMeter metric storage:

# Start the InfluxDB service in the background
./influxd &
# Launch the InfluxDB CLI client
./influx
# Run these CLI commands to create the metrics database
CREATE DATABASE jmeter_perf_metrics;
USE jmeter_perf_metrics;
SHOW MEASUREMENTS;

JMeter Integration with InfluxDB

Add a Backend Listener element to you're test plan, select the InfluxDB backend client implementation, configure the connection endpoint to point to your running InfluxDB instance, and set the target database name to jmeter_perf_metrics as created earlier.

Grafana Metrics Visualization

  1. Download the Grafana package matching your operating system from the official Grafana download page, install the package and launch the Grafana service with the command grafana-server start
  2. Access the Grafana web UI at http://localhost:3000 (default credentials are admin/admin), navigate to Connections > Add new connection, select InfluxDB as the data source type
  3. Configure the data source to point to your InfluxDB instance, set the database name to jmeter_perf_metrics, test the connection and save the configuration
  4. Adjust backend listener parameters to match your visualization requirements:
    • application: Unique application identifier ussed to filter metrics across multiple test runs in Grafana
    • measurement: Name of the InfluxDB measurement where JMeter metrics will be written
    • summaryOnly: Set to true to aggregate all sampler metrics into a single dataset, false to track each sampler's metrics individually
    • samplersRegex: Regular expression to filter which samplers send metrics to InfluxDB, defaults to matching all samplers
    • percentiles: Comma-separated list of percentile values to calculate for response times (common values are 90,95,99)
    • testTitle, eventTags: Custom metadata fields added to InfluxDB records for easier filtering and grouping You can import pre-built JMeter performance dashboards from the official Grafana dashboard gallery to avoid manual panel configuration.

Collecting Server CPU, Memory and Disk Metrics

  1. Install the jp@gc - PerfMon Metrics Collector plugin via the JMeter Plugins Manager
  2. Download the ServerAgent package, transfer it to the server hosting your application under test, extract the archive and launch the agent with the command sh ./startAgent.sh
  3. Add the PerfMon Metrics Collector listener to your JMeter test plan, configure the agent endpoint (IP address of the test server and default port 4444) and select the metrics you want to collect, including CPU utilization, memory consumption, disk I/O and network throughput.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.