Reputation: 4372
According to the doc my application should serve hystrix data under /health. Despite open circuit-breaker the only thing i see under that url is
{"status":"UP"}
I expect to see something like that
{
"hystrix": {
"openCircuitBreakers": [
"somedata::somedata"
],
"status": "CIRCUIT_OPEN"
},
"status": "UP"
}
What did I miss?
My build.gradle
buildscript {
ext {
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.somecompany'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Edgware.SR1'
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-hystrix')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Application class
@EnableCircuitBreaker
@SpringBootApplication
public class HystrixDemoApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDemoApplication.class, args);
}
}
Resource under Hystrix control
@RestController
public class SomeResourceController {
@HystrixCommand(fallbackMethod = "defaultValue", commandProperties = {@HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds", value="1500")})
@RequestMapping(path = "/resource-with-hystrix", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String someResource(){
URI uri = URI.create("http://localhost:8080/some-resource");
RestOperations restTemplate = new RestTemplate();
return restTemplate.getForObject(uri, String.class);
}
private String defaultValue(){
return "local value in case of something goes wrong";
}
}
Upvotes: 0
Views: 2440
Reputation: 31
According to documentation:
The information exposed by the health endpoint depends on the
management.endpoint.health.show-details
property <...> The default value isnever
.
So, in order to show hystrix information you need to set management.endpoint.health.show-details
to either one of:
like so:
management.endpoint.health.show-details = always
The answer provided by msfoster no longer works (as of Spring Boot 2.1.x and cloud release train Greenwich.RELEASE):
Endpoint sensitive flag is no longer customizable as Spring Boot no longer provides a customizable security auto-configuration . Create or adapt your security configuration accordingly
Upvotes: 3
Reputation: 2572
Set Health endpoint as not sensitive(default):
endpoints.health.sensitive=false
Depending on how an endpoint is exposed, the sensitive property may be used as a security hint. For example, sensitive endpoints will require a username/password when they are accessed over HTTP (or simply disabled if web security is not enabled).
From the documentation of the health endpoint:
Shows application health information (when the application is secure, a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated).
Upvotes: 1