1)Hystrix数据监控仪表盘
2)Hystrix日志,是通过Actuator工具来暴露出来
springboot 提供的一个项目指标工具,可以通过Actuator获取项目的各种日志数据
Zuul中默认含有Actuator,所以无需添加
m.e.w.e.i = "*" #暴露所有日志
m.e.w.e.i = health #暴露健康状态日志
m.e.w.e.i = health,beans,mappings,hytrix,stream #暴露多种日志
http://localhost:3001/actuator
没添加依赖前
添加查看所有的依赖
management:
endpoints:
web:
exposure:
include: "*"
查看
当我们启用item服务,
访问http://localhost:3001/actuator/hystrix.stream
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springcloud1artifactId>
<groupId>com.drhjgroupId>
<version>0.0.1-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<groupId>com.drhjgroupId>
<artifactId>sp07-hystrix-dashboardartifactId>
<version>0.0.1-SNAPSHOTversion>
<name>sp07-hystrix-dashboardname>
<description>Demo project for Spring Bootdescription>
<properties>
<java.version>1.8java.version>
properties>
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starterartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboardartifactId>
dependency>
dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>
project>
允许抓取的服务器列表:localhost:…
server:
port: 4001
hystrix:
dashboard:
proxy-stream-allow-list:
- localhost
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);
}
}
启动项目
访问http://localhost:4001/hystrix
刷新http://localhost:3001/item-service/t45t4?token=100,查看服务波动
红色的0表示请求失败数为0
Circuit表示熔断器的状态
使用压力测试工具测试
聚合多台服务器的日志数据,提供给仪表盘显示
添加eureka client, turbine依赖
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springcloud1artifactId>
<groupId>com.drhjgroupId>
<version>0.0.1-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<groupId>com.drhjgroupId>
<artifactId>sp08-turbineartifactId>
<version>0.0.1-SNAPSHOTversion>
<name>sp08-turbinename>
<description>Demo project for Spring Bootdescription>
<properties>
<java.version>1.8java.version>
properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-netflix-eureka-clientartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-netflix-turbineartifactId>
dependency>
dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>
project>
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")
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);
}
}
启动服务
分别运行两个网关
访问 合并日志版本:http://localhost:5001/turbine.stream