1)Hystrix数据监控仪表盘
2)Hystrix日志,是通过Actuator工具来暴露出来
springboot 提供的一个项目指标工具,可以通过Actuator获取项目的各种日志数据
- 健康状态
- spring容器中所有的对象
- spring mvc映射的所有路径
- jvm堆内存镜像
Zuul中默认含有Actuator,所以无需添加
3.暴露日志设置m.e.w.e.i = "*" #暴露所有日志 m.e.w.e.i = health #暴露健康状态日志 m.e.w.e.i = health,beans,mappings,hytrix,stream #暴露多种日志4.查看日志
http://localhost:3001/actuator
没添加依赖前
添加查看所有的依赖
management: endpoints: web: exposure: include: "*"
查看
当我们启用item服务,
访问http://localhost:3001/actuator/hystrix.stream
新建spring boot 项目
这里不添加任何依赖
3.yml配置springcloud1 com.drhj 0.0.1-SNAPSHOT 4.0.0 com.drhj sp07-hystrix-dashboard0.0.1-SNAPSHOT sp07-hystrix-dashboard Demo project for Spring Boot 1.8 org.springframework.boot spring-boot-starterorg.springframework.boot spring-boot-starter-testtest org.springframework.cloud spring-cloud-starter-netflix-hystrix-dashboardorg.springframework.boot spring-boot-maven-plugin
允许抓取的服务器列表:localhost:…
server: port: 4001 hystrix: dashboard: proxy-stream-allow-list: - localhost4.启动类添加注解
package com.drhj.sp07; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; @EnableHystrixDashboard @SpringBootApplication public class Sp07HystrixDashboardApplication { public static void main(String[] args) { SpringApplication.run(Sp07HystrixDashboardApplication.class, args); } }5.测试
启动项目
访问http://localhost:4001/hystrix
刷新http://localhost:3001/item-service/t45t4?token=100,查看服务波动
红色的0表示请求失败数为0
Circuit表示熔断器的状态
使用压力测试工具测试
聚合多台服务器的日志数据,提供给仪表盘显示
1.启动网关Zuul高可用
创建springboot的moudle
添加依赖
添加eureka client, turbine依赖
4.配置application.yml文件springcloud1 com.drhj 0.0.1-SNAPSHOT 4.0.0 com.drhj sp08-turbine0.0.1-SNAPSHOT sp08-turbine Demo project for Spring Boot 1.8 org.springframework.cloud spring-cloud-starter-netflix-eureka-clientorg.springframework.boot spring-boot-starter-testtest org.springframework.cloud spring-cloud-starter-netflix-turbineorg.springframework.boot spring-boot-maven-plugin
spring: application: name: turbine # 2001 eureka # 3001 zuul # 4001 hystrix dashboard server: port: 5001 eureka: client: service-url: defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka turbine: app-config: zuul #多个的话使用,号隔开 cluster-name-expression: new String("default")5.启动类添加注解@EnableTurine
package com.drhj.sp08; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.turbine.EnableTurbine; @EnableTurbine @SpringBootApplication public class Sp08TurbineApplication { public static void main(String[] args) { SpringApplication.run(Sp08TurbineApplication.class, args); } }6.测试
启动服务
分别运行两个网关
访问 合并日志版本:http://localhost:5001/turbine.stream
查看断路器仪表盘
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)