Because hystrix is a single application for monitoring the traffic status. Sometimes we need to view the monitoring status of the whole system comprehensively, so we may need to introduce the monitoring check of turbine. Spring boot admin already has the plug-in spring boot admin server UI turbine
turbine is a collection of hystrix. It shows all the effects of hystrix. The version of spring cloud we use here is
<spring-boot.version>1.5.3.RELEASE</spring-boot.version> <spring-cloud.version>Dalston.SR1</spring-cloud.version> <spring-boot-admin.version>1.5.0</spring-boot-admin.version>
1. Configure package dependencies for turbine
<dependencies> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server</artifactId> <version>${spring-boot-admin.version}</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui</artifactId> <version>${spring-boot-admin.version}</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui-turbine</artifactId> <version>${spring-boot-admin.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine</artifactId> </dependency> </dependencies>
2, Configure startup class
//www.1b23.com @SpringBootApplication @EnableAdminServer @EnableDiscoveryClient @EnableTurbine open class YkbBootAdminServerApplication { companion object { @JvmStatic fun main(args: Array<String>) { SpringApplication.run(YkbBootAdminServerApplication::class.java, *args) } } }
The startup class is configured with @ EnableTurbine
3. Configuration startup item: (application.properties)
spring.boot.admin.routes.endpoints= env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,turbine.stream spring.boot.admin.turbine.location=TGS-SPRING-BOOT-ADMIN management.security.enabled=false security.basic.enabled=false turbine.clusterNameExpression=new String("default") turbine.appConfig=YKB-ACCOUNT-MOBILE turbine.combineHostPort=true
Where endpoints are configured with hystrix.stream and turbine.stream
spring.boot.admin.turbine.location=TGS-SPRING-BOOT-ADMIN is configured
The TGS-SRPING-BOOT-ADMIN instance manages all monitoring
Spring cloud project case www.1b23.com
Last
turbine.appConfig=YKB-ACCOUNT-MOBILEĀ
Represents which apps you can monitor, separated by commas
4. Configure hystrix
YKB account mobile configures the fuse mechanism, which is included in @ SpringCloudApplication
@SpringCloudApplication @EnableZuulProxy @EnableFeignClients open class AccountMobileApplication { //www.1b23.com @LoadBalanced @Bean open fun restTemplate(): RestTemplate { return RestTemplate() } companion object { @JvmStatic fun main(args: Array<String>) { SpringApplication.run(AccountMobileApplication::class.java, *args) } } }
The jar package to be imported is
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zuul</artifactId> </dependency>
Where the application is configured as
server.port=7180 management.port=7181 eureka.instance.prefer-ip-address = true eureka.instance.lease-renewal-interval-in-seconds=10 eureka.instance.lease-expiration-duration-in-seconds=30 eureka.client.service-url.defaultZone= http://eureka.ejuda.net:8761/eureka/ eureka.client.fetch-registry=true eureka.instance.metadata-map.management.port= ${management.port} //Where Eureka. Instance. Metadata map. Management. Port = ${management. Port}
It is necessary. Because the management port is different from the service port