SpringCloud turbine监控实现过程解析
这篇文章主要介绍了SpringCloudturbine监控实现过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
1、pom.xml文件
4.0.0 com.test springcloud 1.0-SNAPSHOT ../ com.test eureka-client-comsumer-feign-hystrix-turbine 0.0.1-SNAPSHOT eureka-client-comsumer-feign-hystrix-turbine DemoprojectforSpringBoot 1.8 Greenwich.SR1 org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-starter-netflix-hystrix-dashboard org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.cloud spring-cloud-starter-netflix-hystrix org.springframework.cloud spring-cloud-starter-netflix-turbine org.springframework.cloud spring-cloud-starter-openfeign org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import org.springframework.boot spring-boot-maven-plugin
主要添加了一下几个依赖:
org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-starter-netflix-hystrix-dashboard org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.cloud spring-cloud-starter-netflix-hystrix org.springframework.cloud spring-cloud-starter-netflix-turbine org.springframework.cloud spring-cloud-starter-openfeign
2、添加注解
packagecom.test.eurekaclientcomsumerfeignhystrixturbine; importcom.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; importorg.springframework.boot.SpringApplication; importorg.springframework.boot.autoconfigure.SpringBootApplication; importorg.springframework.boot.web.servlet.ServletRegistrationBean; importorg.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; importorg.springframework.cloud.netflix.eureka.EnableEurekaClient; importorg.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; importorg.springframework.cloud.netflix.turbine.EnableTurbine; importorg.springframework.cloud.openfeign.EnableFeignClients; importorg.springframework.context.annotation.Bean; @SpringBootApplication @EnableEurekaClient @EnableFeignClients @EnableCircuitBreaker @EnableTurbine @EnableHystrixDashboard /** *Dashboard访问地址:http://localhost:7016/hystrix *在Dashboard输入http://localhost:7016/turbine.stream */ publicclassEurekaClientComsumerFeignHystrixTurbineApplication{ @Bean publicServletRegistrationBeangetServlet(){ HystrixMetricsStreamServletstreamServlet=newHystrixMetricsStreamServlet(); ServletRegistrationBeanregistrationBean=newServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/actuator/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); returnregistrationBean; } publicstaticvoidmain(String[]args){ SpringApplication.run(EurekaClientComsumerFeignHystrixTurbineApplication.class,args); } }
3、application.yml文件配置
server: port:7016 spring: application: name:eureka-client-feign-hystrix-turbine eureka: instance: hostname:localhost prefer-ip-address:true instance-id:${spring.application.name}:${spring.application.instance_id:${server.port}} client: serviceUrl: defaultZone:http://${eureka.instance.hostname}:8761/eureka eureka-provider:#远程服务虚拟主机名 ribbon: NFLoadBalancerRuleClassName:com.netflix.loadbalancer.RoundRobinRule #turbine配置 turbine: aggregator: cluster-config:default app-config:eureka-client-feign-hystrix-turbine,eureka-client-feign-hystrix,eureka-client-feign-hystrix-dashboard cluster-name-expression:"'default'"
4、访问
a)http://localhost:7016/hystrix
b)在dashboard输入:http://localhost:7016/turbine.stream
具体的代码可访问github:https://github.com/812406210/springCloud.git
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。