1.父工程pom.xml中引入actuator依赖
org.springframework.boot spring-boot-starter-actuator
2.服务调用方application.yml中添加相关配置
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
3.服务调用方注册监控Servlet
@Bean
public ServletRegistrationBean getServlet(){
HystrixMetricsStreamServlet streamServlet = new
HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new
ServletRegistrationBean(streamServlet);
registrationBean.setLoadonStartup(1);
registrationBean.addUrlMappings("/actuator/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
4.创建一个新的工程,仪表盘项目,发布到注册中心
server:
port: 9000
eureka:
instance:
hostname: localhost
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}:@project.version@
client:
service-url:
defaultZone: http://localhost:8761/eureka/
register-with-eureka: true
fetch-registry: true
spring:
application:
name: dashboard
@SpringBootApplication
@EnableHystrixDashboard
public class DashBoardApplication {
public static void main(String[] args) {
SpringApplication.run(DashBoardApplication.class,args);
}
}
org.springframework.cloud
spring-cloud-starter-netflix-hystrix
org.springframework.cloud
spring-cloud-starter-netflix-hystrix-dashboard
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
5.启动仪表盘项目,访问项目IP+端口/hystrix



