I am trying to run JMeter in a Docker environment (using Docker Compose) to measure performance metrics (such as CPU and memory usage) of a database with the ServerAgent plugin (v.2.2.3). I use the .jmx file with the code shown below, hoping to return the metric values of CPU among others. However, it returns an empty file, as seen in the attached document. What could be wrong? I build and run the Dockerfile as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Simple MongoDB Insert" enabled="true">
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="MongoDB Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">10</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">10</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.duration">60</longProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Insert MongoDB Document" enabled="true">
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="script">
import com.mongodb.client.MongoClients
import org.bson.Document
def uri = "mongodb://staging:staging@mongodb:27017"
def databaseName = "HortPlant"
def collectionName = "plantFeature"
// Connect to MongoDB
def mongoClient = MongoClients.create(uri)
def database = mongoClient.getDatabase(databaseName)
def collection = database.getCollection(collectionName)
// Create and insert a document
def doc = new Document('plantId', "plant_001")
.append("height", 32.5)
.append("leafCount", 14)
collection.insertOne(doc)
log.info("Inserted document: ${doc.toJson()}")
// ⏱️ Add delay to allow PerfMon to collect data
Thread.sleep(10000) // 10 seconds
// Close connection
mongoClient.close()
</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223Sampler>
<hashTree/>
<ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="Simple Data Writer" enabled="true">
<boolProp name="ResultCollector.error_logging">true</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename">/jmeter_results/mongodb.jtl</stringProp>
</ResultCollector>
<hashTree/>
<kg.apc.jmeter.perfmon.PerfMonCollector guiclass="kg.apc.jmeter.perfmon.PerfMonCollectorGui" testclass="kg.apc.jmeter.perfmon.PerfMonCollector" testname="PerfMon CSV Collector" enabled="true">
<boolProp name="ResultCollector.error_logging">true</boolProp>
<stringProp name="interval">1000</stringProp>
<stringProp name="filename">/jmeter_results/perfmon_only.csv</stringProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<collectionProp name="nodes">
<stringProp name="0">server-agent;4444;cpu;total</stringProp>
<stringProp name="1">server-agent;4444;memory;used</stringProp>
<stringProp name="2">server-agent;4444;disks-io;sda</stringProp>
</collectionProp>
</kg.apc.jmeter.perfmon.PerfMonCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>