4

Monitoring Spring boot application(TestMonitoring) using JMX exporter and Prometheus. Prometheus and spring boot application Pods are up and running in kubernetes cluster. Now the pain is to get JMX exporter running and the application should expose metrics via JMX.

In TestMonitoring application , the application.properties file has the following setting:

endpoints.jmx.enabled=true
spring.jmx.enabled=true

Now how to install the JMX exporter as an agent: i have download the jar and executed:

java -javaagent:./jmx_prometheus_javaagent-0.9.jar=1234:config.yml

In the config.yml -> the following hostPort:xx.x.x.x:30001 (target port of myspring boot application which is available as a service)

The following exception is thrown:

Sep 22, 2017 4:12:31 PM 

io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector collect
SEVERE: JMX scrape failed: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [R              oot exception is java.rmi.ConnectIOException: non-JRMP server at remote endpoint]
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:370)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)
        at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.doScrape(JmxScraper.java:106)
        at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.collect(JmxCollector.java:401)
        at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry.collectorNames(CollectorRegistry.java:99)
        at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry.register(CollectorRegistry.java:50)
        at io.prometheus.jmx.shaded.io.prometheus.client.Collector.register(Collector.java:128)
        at io.prometheus.jmx.shaded.io.prometheus.client.Collector.register(Collector.java:121)
        at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: non-JRMP server at remote               endpoint]
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:142)
        at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:204)
        at javax.naming.InitialContext.lookup(InitialContext.java:415)
        at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1928)
        at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1895)
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)

What could be the reason of the such exception,Just not able to figure it? any suggestions will be very helpful

dkat
  • 213
  • 1
  • 5
  • 14
  • Why are you trying to use JMX together with Spring Boot and not the client lib? – Martin Schröder Sep 24 '17 at 09:06
  • 3
    With the client lib, need to instrument the application with monitoring specific code. Would like to use JMX exporter that fetches jvm metrics and prometheus can be configured to scrape the JMX exporter. So that way my application need not be instrumented with any code. – dkat Sep 25 '17 at 11:25

1 Answers1

0

Try https://github.com/fabric8io/agent-bond
It works fine. Use it like this:

-javaagent:/opt/agent-bond/agent-bond.jar=/etc/config/agent-bond.properties
justvit
  • 1
  • 1