springcloud 中使用 hystrix-dashboard 进行监控的时候启动报错”path”:”/actuator/hystrix.stream”,”status”:404,”error”:”Not Found”
这是因为springboot2.x使用了endpoint
解决办法一:
是在被监控的微服务的bootstrap.yml文件中加入如下配置
management:
endpoints:
web:
exposure:
include: ["hystrix-stream"]
这样就可以了,但是actuator/health就无法访问了,所以还可以选择全部放开。
management:
endpoints:
web:
exposure:
include: '*'
解决办法二:
在启动类上加入
@EnableHystrix
@EnableCircuitBreaker
@EnableHystrixDashboard
在启动类中加入
@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;
}
---------------------
本人采用第二种方式,验证OK!