Turbine访问/actuator/hystrix.stream报错404错误

一共四个服务:

1.eureka server:eureka的服务端

2.eureka-client:服务提供者

3.eureka-consumer-ribbon:服务消费者(使用断路器)

4.hystrix-turbine:监控工具

今天将项目升级,SpringCloud版本升级到Greenwich.RELEASE,SpringBoot版本升级到2.1.3.RELEASE。升级完成后运行报一下错误

com.netflix.turbine.monitor.instance.InstanceMonitor$MisconfiguredHostException: [{"timestamp":"2019-03-07T07:02:10.935+0000","status":404,"error":"Not Found","message":"No message available","path":"/actuator/hystrix.stream"}]
	at com.netflix.turbine.monitor.instance.InstanceMonitor.init(InstanceMonitor.java:318) ~[turbine-core-1.0.0.jar:na]
	at com.netflix.turbine.monitor.instance.InstanceMonitor.access$100(InstanceMonitor.java:103) ~[turbine-core-1.0.0.jar:na]
	at com.netflix.turbine.monitor.instance.InstanceMonitor$2.call(InstanceMonitor.java:235) [turbine-core-1.0.0.jar:na]
	at com.netflix.turbine.monitor.instance.InstanceMonitor$2.call(InstanceMonitor.java:229) [turbine-core-1.0.0.jar:na]
	at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_101]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_101]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_101]
	at java.lang.Thread.run(Unknown Source) [na:1.8.0_101]

解决方法:

2.x以上的版本需要在被监控的项目(eureka-consumer-ribbon)中添加

        @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;
	  }

注意:registrationBean.addUrlMappings("/actuator/hystrix.stream");这个要和你的hystrix-turbine中的默认访问链接一致,不然还是无法访问的

这问题我弄了半天,网上大部分都是说在hystrix-turbine的配置文件中修改默认路径,但是如果不在被监控项目中添加这段话怎么改都是无效的

你可能感兴趣的:(Spring,Cloud)