2

I want to enable actuator for health check in PCF for the non web or batch or commandLineRunner spring boot application.

Could some one please share some details to resolve this issue.

Please let me know if any other details required

I tried the below options

Adding actuator dependency Adding http and jmx related properties

Since localhost:8081/actuator is not accessible could not view endpoints

How to enable url for non web app

Jonas
  • 121,568
  • 97
  • 310
  • 388
Haseena
  • 33
  • 4
  • 2
    What keeps your app running? If it's just a program that runs and then terminates when finished actuator doesn't make sense – Simon Martinelli Dec 10 '22 at 10:04
  • 1
    I second what @SimonMartinelli said. For ephemeral apps, it does not make sense to expose a http endpoint. Metrics should be gathered and pushed to a metrics backend with something like [Prometheus pushgateway](https://prometheus.io/docs/practices/pushing/). Spring Batch provides integration with micrometer, which does that by default on application exit. – Mahmoud Ben Hassine Dec 12 '22 at 13:53

2 Answers2

1

add

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

application.properties

spring.jmx.enabled = true
management.endpoints.jmx.exposure.include=*
management.endpoints.jmx.domain=com.example.demomail
management.endpoints.jmx.unique-names=true

run jconsole find your application name then connect.

find Tab MBeans, find com.example.demomail in left tree.

life888888
  • 835
  • 2
  • 2
  • 8
1

As far as I understand you need to enable the Actuator endpoints.

You must add the Spring Boot Actuator dependency (as you have already done).

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

Then in your application.properties file enable HTTP and JMX support (as you have already done).

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
management.endpoint.jmx.exposure.include=*

Now you will have to push your app to PCF and create a binding to a route to create access for the Actuator endpoint/s.

The URL to access the actuator endpoint will be something like this http://<route-url>/actuator/health

In the command line, I would use something like this to return a list of routes and the URL route of the application.

cf curl /v2/apps/<app-guid>/routes
devblack.exe
  • 428
  • 4
  • 17