diff --git a/springcloud-service-hystrix-dashboard/pom.xml b/springcloud-service-hystrix-dashboard/pom.xml index 25d4e3434f3aeb3c8c0348095536e4a835aa660c..92c9af4fe490184310a5f770eb921715085aa166 100644 --- a/springcloud-service-hystrix-dashboard/pom.xml +++ b/springcloud-service-hystrix-dashboard/pom.xml @@ -35,6 +35,10 @@ org.springframework.boot spring-boot-starter-actuator + + org.springframework.cloud + spring-cloud-starter-netflix-hystrix + diff --git a/springcloud-service-hystrix-dashboard/src/main/java/com/kwan/springcloud/HystrixDashboardApplication.java b/springcloud-service-hystrix-dashboard/src/main/java/com/kwan/springcloud/HystrixDashboardApplication.java index 722e420d3daad52487da865f61b8b8d36f4dc700..6c39f0c09e778beea3133abbd621b2b0eb3409a1 100644 --- a/springcloud-service-hystrix-dashboard/src/main/java/com/kwan/springcloud/HystrixDashboardApplication.java +++ b/springcloud-service-hystrix-dashboard/src/main/java/com/kwan/springcloud/HystrixDashboardApplication.java @@ -4,12 +4,13 @@ package com.kwan.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; + /** - * * http://localhost:9909/hystrix - *@version : 2.2.0 - *@author : qinyingjie - *@date : 2023/1/14 15:33 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/1/14 15:33 */ @EnableHystrixDashboard @SpringBootApplication @@ -19,4 +20,5 @@ public class HystrixDashboardApplication { SpringApplication.run(HystrixDashboardApplication.class, args); } + } diff --git a/springcloud-service-hystrix-dashboard/src/main/resources/application.yaml b/springcloud-service-hystrix-dashboard/src/main/resources/application.yaml index b921836e068209b5c3320b6058f60a6b2cff91f1..5a1f50ca90e7589da5bb091ee468039f08bd1a5e 100644 --- a/springcloud-service-hystrix-dashboard/src/main/resources/application.yaml +++ b/springcloud-service-hystrix-dashboard/src/main/resources/application.yaml @@ -4,4 +4,8 @@ server: spring: application: - name: hystrix-dashboard-service #服务名称 \ No newline at end of file + name: hystrix-dashboard-service #服务名称 + +hystrix: + dashboard: + proxy-stream-allow-list: "localhost" \ No newline at end of file diff --git a/springcloud-service-portal/pom.xml b/springcloud-service-portal/pom.xml index 9fb6186bb77d5ec1fabbf7db093f00ec285004d7..d86558dc28ceb6da327f58fbd1bd7dcbcf2344aa 100644 --- a/springcloud-service-portal/pom.xml +++ b/springcloud-service-portal/pom.xml @@ -34,10 +34,13 @@ spring-cloud-openfeign-core + + org.springframework.boot + spring-boot-starter-actuator + org.springframework.cloud - spring-cloud-starter-hystrix - 1.4.7.RELEASE + spring-cloud-starter-netflix-hystrix diff --git a/springcloud-service-portal/src/main/java/com/kwan/springcloud/PortalApplication.java b/springcloud-service-portal/src/main/java/com/kwan/springcloud/PortalApplication.java index 63e16ab16255c5e6bda9eaabc66027a5d8bfd601..9230b263802baa28251a37e9aba0d9b9031f5684 100644 --- a/springcloud-service-portal/src/main/java/com/kwan/springcloud/PortalApplication.java +++ b/springcloud-service-portal/src/main/java/com/kwan/springcloud/PortalApplication.java @@ -1,10 +1,14 @@ package com.kwan.springcloud; +import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; import org.springframework.boot.SpringApplication; 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.hystrix.EnableHystrix; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; + /** * * http://localhost:8080/portal/hystrix/1 @@ -23,4 +27,14 @@ public class PortalApplication { 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; + } + } diff --git a/springcloud-service-portal/src/main/resources/application.yaml b/springcloud-service-portal/src/main/resources/application.yaml index 33c96658ef73c4cf9f056be70c63cd16d66456a0..71dc686fb76d19ce1c34c25465f25cc272619d8f 100644 --- a/springcloud-service-portal/src/main/resources/application.yaml +++ b/springcloud-service-portal/src/main/resources/application.yaml @@ -31,4 +31,11 @@ ribbon: http: client: enabled: true #开启ribbon超时管理 - ConnectTimeout: 2000 #连接超时时间 \ No newline at end of file + ConnectTimeout: 2000 #连接超时时间 + + +management: + endpoints: + web: + exposure: + include: "*" \ No newline at end of file