简体   繁体   English

在 Docker 容器中使用 JMeter Prometheus 插件(连接被拒绝)

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

I have a Jmeter 5.3 container that runs a basic.jmx test.我有一个运行 basic.jmx 测试的 Jmeter 5.3 容器。 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.测试中包含 Johrstrom 的 Prometheus 插件,配置为端口 9270。如果我在 Docker 之外运行测试,我可以使用“curl localhost:9270”来获取指标。 It's similar when I run the test inside Docker.当我在 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.如果我从 go 到 JMeter Docker 命令行,我可以运行“wget localhost:9270”(卷曲不在图像中)。

Still in the JMeter Docker container, if I do 'wget jmeter:9270' (jmeter is the name of the container) I get connection refused.仍然在 JMeter Docker 容器中,如果我执行 'wget jmeter:9270' (jmeter 是容器的名称)我得到连接被拒绝。 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.我还让 Prometheus 在一个单独的容器中运行,为“jmeter:9270”配置了一个目标,给出了类似的响应,jmeter 名称的正确分辨率,但随后连接被拒绝消息。

I have also tried exposing port 9270, and trying the same 'localhost:9270' from the Docker host.我也尝试过暴露端口 9270,并从 Docker 主机尝试相同的 'localhost:9270'。 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.我应该提一下,我正在按照 Prometheus 侦听器页面上的说明,并将以下属性添加到容器中的 JMeter 中。

-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. -Jprometheus.ip=0.0.0.0 是正确的解决方案,但在我的构建 dockerfile 中存在一个错误,这意味着对运行脚本的更改没有被选中。 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.修复该错误意味着额外的属性已正确添加到运行脚本命令行中,jmeter 可以拾取它并将指标正确呈现给 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.很明显,该财产不见了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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