0

I have a Spring boot project where I use spring-boot-starter-actuator and io.dropwizard.metrics.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>io.dropwizard.metrics</groupId>
        <artifactId>metrics-core</artifactId>
    </dependency>

It generates Metrics that I can access with the url http://myapplication/metrics. I deploy the application on a Wildfly 10 standalone server.

I want to use jmx to read the metrics on jconsole. I configure the application to send metrics with a JMXReporter :

@Configuration
@EnableMetrics
public class MetricsConfiguration extends MetricsConfigurerAdapter {
    @Override
    public void configureReporters(MetricRegistry metricRegistry) {
        registerReporter(JmxReporter.forRegistry(metricRegistry)
                .build())
                .start();
    }
}

When I start the server and deploy the application, logs say :

o.s.b.a.e.j.EndpointMBeanExporter Located managed bean 'metricsEndpoint': registering with JMX server as MBean [portal-ws-jmx:type=Endpoint,name=metricsEndpoint]

Server logs

When I run jconsole, in the Local Process list, there is only JConsole process and some grey PID. If I select a grey PID, it says "The management agent is not enable on this process".

I also tried to use the Remote Process connection :

JConsole

But this doesn't work.

I tried to set the jvm variable :

  • -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false

and the property :

  • spring.jmx.enabled=true

It also doesn't work.

What can I do read jmx metrics with jconsole ?

YLombardi
  • 1,755
  • 5
  • 24
  • 45

2 Answers2

2

Here's the set of command line arguments I use to produce a working spring-boot application (albeit using Tomcat, not Wildfly) that exposes things through JConsole:

cmd="$cmd -Dcom.sun.management.jmxremote"
cmd="$cmd -Dcom.sun.management.jmxremote.port=9899"
cmd="$cmd -Dcom.sun.management.jmxremote.rmi.port=9811"
cmd="$cmd -Dcom.sun.management.jmxremote.authenticate=false"
cmd="$cmd -Dcom.sun.management.jmxremote.ssl=false"
cmd="${cmd} -Djava.rmi.server.hostname=<IP_OF_YOUR_SERVER>"

Note that the application runs on and is accessed through port 9800 (in my case). However, ports 9811 and 9899 are also open for dealing with JMX (as above). You'll also want to insure that the 3 ports are accessible through any firewall you might have setup.

Good Luck

Jeff Bennett
  • 996
  • 7
  • 18
1

I found a solution here : https://dzone.com/articles/remote-jmx-access-wildfly-or

My issue come from Wildfly. When I run jconsole, I need jboss-cli-client.jar and tools.jar to jconsole classpath :

$JAVA_HOME/bin/jconsole -J-Djava.class.path=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/jconsole.jar:/opt/wildfly-8.2.0.Final/bin/client/jboss-cli-client.jar

Now it works, I can use "service:jmx:remote+http://localhost:9990" to connect to jmx.

YLombardi
  • 1,755
  • 5
  • 24
  • 45