Reputation: 1880
When using Spring Boot health actuator
http://localhost:8080/health
{"status":"UP","diskSpace":{"status":"UP","total":122588196864,"free":59227926528,"threshold":10485760},"mongo":{"status":"UP","version":"3.2.6"}}
Now I want to check for other condition, so as to check dependent action are triggered when status is down. I want something like
{"status":"Down"}
Upvotes: 1
Views: 3590
Reputation: 837
First disable the default /health endpoint or customize it to some different endpoint. You can disable it follow
endpoints.health.disabled=true
Once this is disabled, implement your own custom endpoints at /health and define your custom conditions with whatever you like to check.
You can take a look here for creating custom endpoints Don't forget to use test profile while creating custom endpoint
Upvotes: 0
Reputation: 30809
You can write your custom 'Health Indicator' which would override the default Health Indicator and write your implementation (e.g. Always return status as down
).
Now, as this is only needed to test the app, I would recommend annotating this with @Profile
so that it only gets activated when the app is started with let's say test
profile, e.g.:
@Component
@Profile("test")
public class MyHealthIndicator implements HealthIndicator {
By this way, if you start the app with any profile other than test
, default HealthIndicator
will be used.
Upvotes: 2