简体   繁体   中英

using JMeter Prometheus plugin within a Docker container (connection refused)

I have a Jmeter 5.3 container that runs a basic.jmx test. Within the test is Johrstrom's Prometheus plugin, configured for port 9270. If I run the test outside of Docker, I can use 'curl localhost:9270' to get the metrics. It's similar when I run the test inside Docker. If I go to the JMeter Docker command line, I can run 'wget localhost:9270' (curl isn't in the image) and it gives me the metrics.

Still in the JMeter Docker container, if I do 'wget jmeter:9270' (jmeter is the name of the container) I get connection refused. The response does include

Resolving jmeter (jmeter)... 172.18.0.3

So I'm happy that it's not a failure due to the container name. I also have Prometheus running in a separate container, having a target configured for 'jmeter:9270' gives a similar response, the correct resolution of the jmeter name but then connection refused message.

I have also tried exposing port 9270, and trying the same 'localhost:9270' from the Docker host. That doesn't work either, I get empty reply from server.

What have I missed in the configuration that is preventing me from connecting between containers? Or even why I get 'connection refused' within the same container.

I should mention that I'm following the instructions on the Prometheus listener page and adding the following property to JMeter in the container.

-Jprometheus.ip=0.0.0.0

However I have also tried without this setting and I still get connection refused.

Found the issue. The -Jprometheus.ip=0.0.0.0 was the correct solution, but there was a bug in my build dockerfile that meant the change to the run script wasn't being picked up. Fixing that bug meant the extra property was correctly added to the run script command line, jmeter could pick it up and the metrics are correctly presented to Prometheus.

To find this, I ran the container and then went into the command line to confirm the script. It was clear to see the property was missing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM