Using smart-doc to Generate JMeter Performance Test Scripts and Integrate with Prometheus and Grafana
This article explains how to leverage smart-doc to automatically generate JMeter performance testing scripts from API code, import them into JMeter, set up Prometheus monitoring and Grafana dashboards, and highlights the automation benefits for backend development and operations workflows.
In the software development lifecycle, automatically generating API documentation and performance testing scripts greatly improves efficiency and product quality. Since version 3.0.1, smart-doc can also generate JMeter performance test scripts, allowing developers to handle both tasks conveniently.
2. Smart-doc generates JMeter scripts
Smart-doc can create ready‑to‑run JMeter scripts directly from source code annotations, eliminating manual script writing. Ensure the smart-doc plugin is added to your project and configure it in pom.xml as shown in the article.
Run the command mvn -Dfile.encoding=UTF-8 smart-doc:jmeter to let smart-doc scan the code, extract comments, and produce the JMeter script.
Import the generated script into JMeter via File → Open and start the test.
2.3 Configure Prometheus monitoring
Install the JMeter Prometheus plugin in JMeter/lib/ext , then add a Prometheus Listener to your test plan. Adjust jmeter.properties to set prometheus.ip=0.0.0.0 so Prometheus can reach the listener.
In prometheus.yml add a scrape config such as:
scrape_configs:
- job_name: 'jmeter'
static_configs:
- targets: ['
:9270']Start JMeter; it will expose metrics on port 9270. Verify by visiting http://localhost:9270/metrics .
Start Prometheus; it will scrape the JMeter metrics and display the target in its UI.
6. Configure Grafana
Import the official Prometheus‑JMeter dashboard (ID 14927) into Grafana, select the Prometheus data source, and you will see real‑time performance metrics visualized.
3. Advantages of using smart-doc for performance testing
Automation : Generates JMeter scripts automatically from source code.
Accuracy : Scripts stay in sync with API definitions.
Flexibility : Supports various configuration options to tailor scripts.
By combining smart-doc with JMeter, Prometheus, and Grafana, teams can automate API documentation, create performance tests, and monitor results efficiently, significantly boosting development and testing productivity.
Tongcheng Travel Technology Center
Pursue excellence, start again with Tongcheng! More technical insights to help you along your journey and make development enjoyable.
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.