Exposing JMX Metrics to a Port Spring Boot

Viewed 114

I want to expose JMX metrics for my spring boot application to a specific port below is my pom:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
        
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.3.8.RELEASE</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
     </dependencies>

My Application.properties:

spring.jmx.enabled=true

I am running my application using below command:

java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=6001 
-Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 
-Djava.rmi.server.hostname=<My IP> -Dcom.sun.management.jmxremote.rmi.port=6001 -jar myapplication.jar

I am not able to access the metrics at <My IP>:6001. Any help how I can expose the metrics for my Spring Boot?

0 Answers
Related