4

I went via almost all docs and all but not able to get grip on this mysterious stuff. so my question - Can I use my standalone spring boot app to monitor health and other metrics of my app via http jmx url? Do I need to configure something else for this? I have added below dependency in boot app.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </dependency>

I have also configured below properties in my config file.

management.endpoints.web.exposure.include=*
management.endpoints.jmx.unique-names=true
management.server.port=8080
management.server.ssl.enabled=false

When I try to hit URL : http://localhost:8080/actuator/jolokia/health I am not able to see any results.

Also tried adding custom end point like below but not working.

@Endpoint(id="mypoint")
    @Component
    public class myPointEndPoint {
        @ReadOperation
        public String mypoint(){
            return "Hello" ;
        }

with additional property
management.endpoint.mypoint.enabled=true

Tukaram Bhosale
  • 348
  • 3
  • 17

1 Answers1

4

The problem is the url you are trying to invoke. First, retrieve the possible mbeans with: http://localhost:8080/actuator/jolokia/list

When you take a look at the Health mbean, you must provide the unique name and the operation (op).

In my case, it looked like: http://localhost:8080/actuator/jolokia/exec/org.springframework.boot:type=Endpoint,name=Health,identity=4200098/health

Also check the Jolokia documentation: https://jolokia.org/reference/html/index.html

  • Thank you. It means it works without web app. I will try above solution and get back to you – Tukaram Bhosale Sep 25 '18 at 11:16
  • First URL to get list is not working. Trying out more stuff from doc. – Tukaram Bhosale Sep 26 '18 at 17:28
  • 1
    I pushed the example I used: https://github.com/mydeveloperplanet/myspringactuatorplanet/tree/feature/jmxendpoints The last commit shows which changes I made in order to get it working. I also added something to the application.properties but I am not sure if it is really necessary. – mydeveloperplanet Sep 27 '18 at 15:56
  • Thank you. I will check it out. – Tukaram Bhosale Sep 28 '18 at 08:37
  • 1
    I went via code and saw starter-web dependency there. As I need JMx to work in standalone app, I don't want to add that. Or if l I add it just for JMX purpose(not main functionality in my app but want to add as complimentory), does it make sense ? – Tukaram Bhosale Sep 28 '18 at 12:52
  • I am quite lost now about how your application is designed. Is your Spring Boot application running without jolokia? And what kind of application is it anyway? It is either a Spring Web MVC application or a Spring Reactive Web application, right? – mydeveloperplanet Sep 28 '18 at 18:48
  • Yes, I am using jolokia dependency. My application doesn't contain any web starter dependency and it's standalone app not having any web invocation via url. I am using spring for its scheduling capability and nothing else. So as asked in main question, my question still remains same, is it possible for jolokia to expose JMX over HTTP without having inbuilt web server in application. – Tukaram Bhosale Sep 29 '18 at 10:32
  • I guess my doubt is correct that I cant use this jolokia kind of exposure in spring boot(non web) standalone app. When I removed web dependency, its not giving any result on hitting URL. – Tukaram Bhosale Sep 30 '18 at 14:02