From 6858a3d29457306c86a06eb41fd6015aa856fda9 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Wed, 2 Dec 2015 12:24:19 -0700 Subject: [PATCH] Provide basic docs on hystrix and turbine usage. Functionality was completed in https://github.com/spring-cloud/spring-cloud-netflix/commit/38055b586df8bf7a3798f558c32d0bce109059f5 fixes gh-53 --- .../main/asciidoc/spring-cloud-consul.adoc | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/docs/src/main/asciidoc/spring-cloud-consul.adoc b/docs/src/main/asciidoc/spring-cloud-consul.adoc index 79542c1e..e8d786d1 100644 --- a/docs/src/main/asciidoc/spring-cloud-consul.adoc +++ b/docs/src/main/asciidoc/spring-cloud-consul.adoc @@ -190,26 +190,51 @@ You can change the data key using `spring.cloud.consul.config.data-key`. TODO: document Spring Cloud Consul Bus +[[spring-cloud-consul-hystrix]] +== Circuit Breaker with Hystrix -[[spring-cloud-consul-ui]] -== Proxy Consul UI through Spring Cloud Application +Applications can use the Hystrix Circuit Breaker provided by the Spring Cloud Netflix project by including this starter in the projects pom.xml: `spring-cloud-starter-hystrix`. Hystrix doesn't depend on the Netflix Discovery Client. The `@EnableHystrix` annotation should be placed on a configuration class (usually the main class). Then methods can be annotated with `@HystrixCommand` to be protected by a circuit breaker. See http://projects.spring.io/spring-cloud/spring-cloud.html#_circuit_breaker_hystrix_clients[the documentation] for more details. -To enable the Consul Web UI please read https://www.consul.io/intro/getting-started/ui.html[the documentation] under the "Self-hosted Dashboard" section. -After you have enabled the Consul Web UI in the Agent, place the `@EnableConsulUi` annotation on a `@Configuration` class. `@EnableConsulUi` enables a zuul proxy configured to proxy to the Consul UI running on the Consul Agent. The UI will be available by default at `/consul/ui/`. To change the prefix the UI will be available under, set the `spring.cloud.consul.ui.path` property. +[[spring-cloud-consul-turbine]] +== Hystrix metrics aggregation with Turbine and Consul + +Turbine (provided by the Spring Cloud Netflix project), aggregates multiple instances Hystrix metrics streams, so the dashboard can display an aggregate view. Turbine uses the `DiscoveryClient` interface to lookup relevant instances. To use Turbine with Spring Cloud Consul, configure the Turbine application in a manner similar to the following examples: + +.pom.xml +---- + + org.springframework.cloud + spring-cloud-netflix-turbine + + + org.springframework.cloud + spring-cloud-starter-consul-discovery + +---- + +Notice that the Turbine dependency is not a starter. The turbine starter includes support for Netflix Eureka. .application.yml ---- -spring: - cloud: - consul: - ui: - path: /admin/** +spring.application.name: turbine +applications: consulhystrixclient +turbine: + aggregator: + clusterConfig: ${applications} + appConfig: ${applications} ---- -This will make the Web UI available under `/admin/ui/`. +The `clusterConfig` and `appConfig` sections must match, so it's useful to put the comma-separated list of service ID's into a separate configuration property. -By exposing the Consul Web UI via a Spring Boot application, you can secure access to it via the same Spring Security tools that you use to secure the rest of the application. - -[CAUTION] -The Consul Admin UI expects the Consul HTTP API to be available at `/v1`. If the `server.contextPath` is not `/` or your application has a route at `/v1`, then the Consul Web UI will fail to proxy. +.Turbine.java +---- +@EnableTurbine +@EnableDiscoveryClient +@SpringBootApplication +public class Turbine { + public static void main(String[] args) { + SpringApplication.run(DemoturbinecommonsApplication.class, args); + } +} +---- \ No newline at end of file