使用JMX Exporter和Prometheus监视Spring Boot应用程序(TestMonoriting)。Prometheus和Spring Boot应用程序POD在Kubernetes群集中启动并运行。现在,痛苦是要使JMX出口商运行,并且应用程序应通过JMX暴露指标。
在testmonitoring应用程序中,应用程序文件具有以下设置:
endpoints.jmx.enabled=true
spring.jmx.enabled=true
现在如何将JMX出口商安装为代理:我已经下载了罐子并执行:
java -javaagent:./jmx_prometheus_javaagent-0.9.jar=1234:config.yml
在config.yml->下面的Hostport:xx.x.x.x:30001(可作为服务可用的MySpring引导应用程序的目标端口)
抛出以下例外:
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)
这种例外的原因是什么,只是无法弄清楚它?任何建议都将非常有用
尝试https://github.com/fabric8io/agent-bond
它可以正常工作。这样使用:
-Javaagent://opt/agent-bond/agent-bond.jar=/etc/config/agent-bond.properties