johrstrom / jmeter-prometheus-plugin

A Prometheus Listener for Apache JMeter that exposes results in an http API
Apache License 2.0
166 stars 110 forks source link

Couldn't start http server #86

Closed beemi closed 4 years ago

beemi commented 4 years ago

Hi,

I have added IP and Port number in user.properties file in JMETER_BIN but I get NPE, Prometheus running in another ser er.

user.properties prometheus.ip= prometheus.port=9270

image

2020-08-20 16:45:45,921 ERROR c.g.j.l.PrometheusListener: Couldn't start http server java.lang.NullPointerException: null at com.github.johrstrom.listener.PrometheusServer.start(PrometheusServer.java:148) ~[jmeter-prometheus-plugin-0.6.0.jar:?] at com.github.johrstrom.listener.PrometheusListener.testStarted(PrometheusListener.java:142) [jmeter-prometheus-plugin-0.6.0.jar:?] at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfStart(StandardJMeterEngine.java:206) [ApacheJMeter_core.jar:5.2.1] at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:381) [ApacheJMeter_core.jar:5.2.1] at java.lang.Thread.run(Thread.java:834) [?:?] 2020-08-20 16:45:46,192 ERROR c.g.j.l.PrometheusListener: Couldn't stop http server java.lang.NullPointerException: null at com.github.johrstrom.listener.PrometheusServer.stop(PrometheusServer.java:166) ~[jmeter-prometheus-plugin-0.6.0.jar:?] at com.github.johrstrom.listener.PrometheusListener.testEnded(PrometheusListener.java:109) [jmeter-prometheus-plugin-0.6.0.jar:?] at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:218) [ApacheJMeter_core.jar:5.2.1] at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:492) [ApacheJMeter_core.jar:5.2.1] at java.lang.Thread.run(Thread.java:834) [?:?]

beemi commented 4 years ago

2020-08-21 15:54:18,970 ERROR c.g.j.l.PrometheusListener: Couldn't start http server 2020-08-21 15:56:19,542 ERROR c.g.j.l.PrometheusListener: Couldn't stop http server

beemi commented 4 years ago

Here is my Prometheus config

`scrape_configs:

Tried passing IP as a command-line argument as below

jmeter -Dprometheus.ip={metricsHOST_IP} -f -n -t healthCheck.jmx

Getting exception 2020-08-26 15:05:22,175 ERROR c.g.j.l.PrometheusListener: Couldn't start http server java.net.BindException: Can't assign requested address at sun.nio.ch.Net.bind0(Native Method) ~[?:?] at sun.nio.ch.Net.bind(Net.java:461) ~[?:?] at sun.nio.ch.Net.bind(Net.java:453) ~[?:?] at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227) ~[?:?] at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80) ~[?:?] at sun.net.httpserver.ServerImpl.bind(ServerImpl.java:134) ~[jdk.httpserver:?] at sun.net.httpserver.HttpServerImpl.bind(HttpServerImpl.java:54) ~[jdk.httpserver:?] at com.github.johrstrom.listener.PrometheusServer.start(PrometheusServer.java:154) ~[jmeter-prometheus-plugin-0.6.0.jar:?] at com.github.johrstrom.listener.PrometheusListener.testStarted(PrometheusListener.java:142) [jmeter-prometheus-plugin-0.6.0.jar:?] at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfStart(StandardJMeterEngine.java:206) [ApacheJMeter_core.jar:5.2.1] at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:381) [ApacheJMeter_core.jar:5.2.1] at java.lang.Thread.run(Thread.java:834) [?:?]

johrstrom commented 4 years ago

Hi sorry for the delay. -Dprometheus.ip={metricsHOST_IP} this should be the IP of the jmeter server (where the jmeter process is running), not the prometheus host. The idea here is that it you can bind the jmeter server to say 0.0.0.0 to bind to all interfaces.

beemi commented 4 years ago

Hi John,

No problem, thanks for the plugin.

Its works with -Dprometheus.ip=0.0.0.0

I see metrics now. image

rahul01may commented 3 months ago

@johrstrom is that possible multiple JMX on same machine can write metric on localhost:9270.

I have 6 project and all 6 project need to run parallel .is that possible all 6 JMX file can write data on localhost:9270/metrics

johrstrom commented 3 months ago

I have 6 project and all 6 project need to run parallel .is that possible all 6 JMX file can write data on localhost:9270/metrics

No, becuase each jmeter server (jmx file) would be a different port. Seems like you need to combine all 6 projects (use cases?) into 1 jmx file for the type of thing you're looking to do.