提交 e84c3b59 编写于 作者: Q qinyingjie

fix:加入dashboard

上级 52c11347
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
</dependencies> </dependencies>
......
...@@ -4,12 +4,13 @@ package com.kwan.springcloud; ...@@ -4,12 +4,13 @@ package com.kwan.springcloud;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
/** /**
*
* http://localhost:9909/hystrix * http://localhost:9909/hystrix
*@version : 2.2.0 *
*@author : qinyingjie * @author : qinyingjie
*@date : 2023/1/14 15:33 * @version : 2.2.0
* @date : 2023/1/14 15:33
*/ */
@EnableHystrixDashboard @EnableHystrixDashboard
@SpringBootApplication @SpringBootApplication
...@@ -19,4 +20,5 @@ public class HystrixDashboardApplication { ...@@ -19,4 +20,5 @@ public class HystrixDashboardApplication {
SpringApplication.run(HystrixDashboardApplication.class, args); SpringApplication.run(HystrixDashboardApplication.class, args);
} }
} }
...@@ -5,3 +5,7 @@ server: ...@@ -5,3 +5,7 @@ server:
spring: spring:
application: application:
name: hystrix-dashboard-service #服务名称 name: hystrix-dashboard-service #服务名称
hystrix:
dashboard:
proxy-stream-allow-list: "localhost"
\ No newline at end of file
...@@ -34,10 +34,13 @@ ...@@ -34,10 +34,13 @@
<artifactId>spring-cloud-openfeign-core</artifactId> <artifactId>spring-cloud-openfeign-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>1.4.7.RELEASE</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.kwan.springcloud; package com.kwan.springcloud;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix; import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
/** /**
* *
* http://localhost:8080/portal/hystrix/1 * http://localhost:8080/portal/hystrix/1
...@@ -23,4 +27,14 @@ public class PortalApplication { ...@@ -23,4 +27,14 @@ public class PortalApplication {
SpringApplication.run(PortalApplication.class, args); SpringApplication.run(PortalApplication.class, args);
} }
@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
} }
...@@ -32,3 +32,10 @@ ribbon: ...@@ -32,3 +32,10 @@ ribbon:
client: client:
enabled: true #开启ribbon超时管理 enabled: true #开启ribbon超时管理
ConnectTimeout: 2000 #连接超时时间 ConnectTimeout: 2000 #连接超时时间
management:
endpoints:
web:
exposure:
include: "*"
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册