How to Visualize JMeter Performance Data with Grafana, InfluxDB, and Prometheus
This tutorial walks through the end‑to‑end setup of JMeter performance testing data collection using Backend Listener, sending metrics to InfluxDB, and visualizing real‑time TPS, response time, and error rates in Grafana, as well as monitoring OS metrics with node_exporter, Prometheus, and Grafana.
Overview of Common Monitoring Points
The article starts by listing typical monitoring targets such as operating system, application server, middleware, queue, cache, database, network, frontend, load balancer, web server, storage, and code, then focuses on the most frequently used components.
JMeter + InfluxDB + Grafana Data Flow
JMeter’s console or HTML reports only show limited curves (TPS, response time, error rate). To obtain real‑time metrics, the Backend Listener can send data asynchronously to InfluxDB (or Graphite). The article explains the configuration steps and shows the resulting architecture diagram.
private void addMetrics(String transaction, SamplerMetric metric) {
// FOR ALL STATUS
addMetric(transaction, metric.getTotal(), metric.getSentBytes(), metric.getReceivedBytes(), TAG_ALL, metric.getAllMean(), metric.getAllMinTime(),
metric.getAllMaxTime(), allPercentiles.values(), metric::getAllPercentile);
// FOR OK STATUS
addMetric(transaction, metric.getSuccesses(), null, null, TAG_OK, metric.getOkMean(), metric.getOkMinTime(),
metric.getOkMaxTime(), okPercentiles.values(), metric::getOkPercentile);
// FOR KO STATUS
addMetric(transaction, metric.getFailures(), null, null, TAG_KO, metric.getKoMean(), metric.getKoMinTime(),
metric.getKoMaxTime(), koPercentiles.values(), metric::getKoPercentile);
metric.getErrors().forEach((error, count) -> addErrorMetric(transaction, error.getResponseCode(),
error.getResponseMessage(), count));
}This code adds total, success, and failure metrics to the metric collection before they are sent.
@Override
public void writeAndSendMetrics() {
........ if (!copyMetrics.isEmpty()) { try { if (httpRequest == null) {
httpRequest = createRequest(url);
}
StringBuilder sb = new StringBuilder(copyMetrics.size()*35);
for (MetricTuple metric : copyMetrics) { // Add timestamp in nanosecond from epoch (default in InfluxDB)
sb.append(metric.measurement)
.append(metric.tag)
.append(" ")
.append(metric.field)
.append(" ")
.append(metric.timestamp + "000000")
.append("
");
}
StringEntity entity = new StringEntity(sb.toString(), StandardCharsets.UTF_8);
httpRequest.setEntity(entity);
lastRequest = httpClient.execute(httpRequest, new FutureCallback<HttpResponse>() {
@Override public void completed(final HttpResponse response) { int code = response.getStatusLine().getStatusCode();
if (MetricUtils.isSuccessCode(code)) {
if (log.isDebugEnabled()) {
log.debug("Success, number of metrics written: {}", copyMetrics.size());
}
} else {
log.error("Error writing metrics to influxDB Url: {}, responseCode: {}, responseBody: {}", url, code, getBody(response));
}
}
@Override public void failed(final Exception ex) {
log.error("failed to send data to influxDB server : {}", ex.getMessage());
}
@Override public void cancelled() {
log.warn("Request to influxDB server was cancelled");
}
});
........
}
}After metrics are collected, they are formatted and posted to InfluxDB via HTTP.
InfluxDB Storage Structure
Two measurements are created: events (stores test‑tile and event tags) and jmeter (stores application name, transaction statistics, and matches the console output). Grafana queries these measurements to draw time‑series graphs.
Grafana Configuration for JMeter
Configure an InfluxDB data source in Grafana, then import the official JMeter dashboard (ID 5496). The dashboard displays total TPS, 95th‑percentile response time, and per‑transaction statistics in real time.
Example Test Scenario
A simple JMeter test plan with 10 threads, 10 iterations, and 2 HTTP requests generates 200 requests. The article shows screenshots of the JMeter console, the generated HTML report, and the corresponding Grafana panels, confirming that the data matches.
node_exporter + Prometheus + Grafana Data Flow
For system‑level monitoring, the article introduces node_exporter , shows how to start it (listening on port 9200), and explains that it exposes standard Linux counters (CPU, memory, etc.).
Prometheus is downloaded, extracted, and configured with a scrape_config that targets the node_exporter endpoint. After starting Prometheus, a Grafana data source for Prometheus is added and the official node_exporter dashboard (ID 11074) is imported.
Data Logic Example
The article presents a Prometheus query that calculates CPU usage by combining system, user, iowait, and idle counters:
avg(irate(node_cpu_seconds_total{instance=~"$node",mode="system"}[30m])) by (instance)
+ avg(irate(node_cpu_seconds_total{instance=~"$node",mode="user"}[30m])) by (instance)
+ avg(irate(node_cpu_seconds_total{instance=~"$node",mode="iowait"}[30m])) by (instance)
+ 1 - avg(irate(node_cpu_seconds_total{instance=~"$node",mode="idle"}[30m])) by (instance)This query demonstrates how Grafana retrieves raw counters from Prometheus and visualizes them.
Conclusion
The key takeaway is that monitoring tools only display data that the monitored components expose; understanding the source and meaning of each metric is essential for accurate performance analysis.
Original source: https://www.cnblogs.com/siguadd/p/14878035.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
