Spring Boot health seems to return health check UP while context not refreshed - spring

While starting a webbapp, we have a S3InboundFileSynchronizer that loads files during a little time.
We would need to don't let the web server available until all files are loaded. However, the /health endpoint seems available and accessed by our cloud manager to admit it can switch between the previous instance and the one that is starting.
How is it possible to block /health actuator access while the files are loading ?
I tried with #EventListener(classes = { ContextRefreshedEvent.class }) but it doesn't seem to have effect on this... :/
Please help

Related

Even though the spring application is shut down in the spring eureka server, it routes to the terminated application. how do i solve it?

When I checked the Eureka Dashboard, I confirmed that the application was terminated normally and was not displayed, but after that, it was routed to the terminated Spring application for about 30 seconds and gave a 500 error.
I think it's probably cached in eureka. I'd rather not be routed even for one second rather than a way to reduce the period.
Please let me know if there is any material or method that can help me thank you.
I don't want to be routed any more to Spring applications that are terminated in Spring eureka.

How to change the default health endpoint used by spring boot admin

I'd like to have a new on-demand health check endpoint for my service through implementation of indicator. The problem was the on-demand one would be called by default `/actuator/health`, so I have split the default health endpoint into two health groups `/actuator/health/default & /actuator/health/on-demand` as I didn't find any way to remove the on-demand directly from `/actuator/health`.
Now a new issue emerged, by default, spring boot admin will hit /actuator/health to get corresponding info, I was wondering it's possible to ask him to hit /actuator/health/default instead?
BTW, I only have admin client, without any recovery service
haha, this config is the answer: spring.boot.admin.client.instance.health-url

Make spring-boot 2.2.0 report status = UP, even when the DB is down?

Up to spring-boot 2.1.9, I used to set management.health.defaults.enabled = false to decouple the /health endpoint overall status from the database status.
As of 2.2.0, that specific setting no longer works that way (see: SpringBoot 2.1.9 -> 2.2.0 - health endpoint no longer works).
Is there a way to configure spring-boot to decouple the overall status of the /health endpoint from whether or not the datasource is up?
I'm inclined to just make my own endpoint hardcoded to return a status of 200.
I don't really understand what you're trying to do and how disabling all defaults achieved what you've described.
What would be the point of having an endpoint that returns 200 unconditionally? That's seriously misleading IMO.
If you do not want the datasource health indicator, then you can disable that (and only that) using management.health.db.enabled=false.
If you want the datasource health check but want to be able to ignore it, create a group that exclude the db health check and use that for monitoring. See the documentation for more details

Spring Boot health-based load balancing

I'm using Spring Boot for microservices, and I came accross and issue with load balancing.
Spring Actuator adds special health and metrics endpoint to the apps; with this, some basic information can be acquired from the running instances.
What I would like to do, is to a create a (reverse)proxy (e.g. with Zuul and/or Ribbon?), which creates a centralized load balancer, that selects instances by their health status.
For example, I have the following microservices
client
proxy (<- I would like to implement this)
server 1
server 2
When the client sends an http request to the proxy, the proxy should be able to decide, which of the to server instances has the least load, and forward request to that one.
Is there an easy way to do this?
Thanks,
krisy
If you want to make a choice on various load-data, you could implement custom HealthIndicators that accumulate some kind of 'load over time' data, use this in your load balancer to decide where to send traffic.
All custom health indicators will be picked up by spring-boot, and invoked on the actuator /health endpoint.
#Component
class LoadIndicator implements HealthIndicator {
#Override
Health health() {
def loadData = ... do stuff to gather whatever load
return Health.up()
.withDetail("load", loadData)
.build();
}
}
Perhaps you could already use some of spring-boots metrics already, there's multiple endpoints in the actuator. /beans, /trace, /metrics. Should be possible to find that data in your application too.

Hystrix Dashboard with Turbine issue

I have multiple service that are mapped thru zuul so my turbine project looks for hystrix.stream from the zuul project.
I think i have setup everyting right because I can see the hits getting updated properly. But the below section for Thread Pools keeps on loading what am i missing here and whats the use of it, couldnot find anything that can help me to understand it actual use.Here is the screenshot of my dahsboard.
Hystrix Dashboard Image
Let me know if more info is needed for the same.

Resources