How to check if the eureka health checking is working? And how to configure ?

592 views
Skip to first unread message

baggi...@gmail.com

unread,
Aug 18, 2016, 1:40:56 AM8/18/16
to eureka_netflix
I just get started in spring boot and spring cloud, i wrote a eureka client and server.
I want to check if the health checking is working no not .


i had add "eureka.client.healthcheck.enabled: true" to my application.properties on client side.

Just need this configuration right ?Anything else?

bo wang

unread,
Aug 18, 2016, 2:22:39 AM8/18/16
to eureka_netflix
 I had solved this.

I register a EurekaHealthCheckHandler , and print some text into log.

    @Bean
@ConditionalOnMissingBean
public EurekaHealthCheckHandler eurekaHealthCheckHandler() {
return new EurekaHealthCheckHandler(new EurekaRemoteStatusExcludedHealthAggregator());
}
}

public class EurekaRemoteStatusExcludedHealthAggregator extends OrderedHealthAggregator {


private int count = 1;

public EurekaRemoteStatusExcludedHealthAggregator() {
System.out.println("####################################hello health checking is start");
}

@Override
protected Status aggregateStatus(List<Status> candidates) {
System.out.println("####################################hello health checking is starting......" + count++ +
new Date());
List<Status> candidatesWithoutEurekaRemoteStatus = candidates.stream()
.filter(candidate -> !isEurekaRemoteStatusCandidate(candidate))
.collect(Collectors.toList());

return super.aggregateStatus(candidatesWithoutEurekaRemoteStatus);
}

private boolean isEurekaRemoteStatusCandidate(Status candidate)
{
return candidate.getDescription().equalsIgnoreCase("Remote status from Eureka server");
}
}  

在 2016年8月18日星期四 UTC+8下午1:40:56,bo wang写道:
Reply all
Reply to author
Forward
0 new messages