我有一个使用Spring Cloud的微服务项目,来自父级的代码片段:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
所有服务都在Eureka 服务器下运行:
所有的服务都运行良好。我可以打电话给 Postman 打适当的电话,一切都很好。
我有一个单独的服务来处理Hystrix dashboard,这是pom
的一个片段:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
配置主类:
@SpringBootApplication
@EnableHystrixDashboard
public class DashboardApp {
public static void main(String[] args) {
SpringApplication.run(DashboardApp.class, args);
}
}
和配置yaml
文件:
spring:
application:
name: Dashboard
server:
port: 8000
eureka:
client:
fetchRegistry: true
registerWithEureka: false
serviceUrl:
defaultZone: http://localhost:8761/eureka
我有下一个 Jmeter 板看:
来自控制台的完整堆栈跟踪是here。以下是一些代码片段:
2018-04-12 11:28:25.089 ERROR 15762 --- [qtp295055909-16] ashboardConfiguration$ProxyStreamServlet : Error proxying request: http://localhost:8082/hystrix.stream
java.lang.RuntimeException: org.eclipse.jetty.io.EofException
at org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardConfiguration$ProxyStreamServlet.doGet(HystrixDashboardConfiguration.java:208)
....
Caused by: org.eclipse.jetty.io.EofException: null
...
Caused by: java.io.IOException: Broken pipe
...
使用Spring执行机构可进行维修:
pom
代码片段:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
配置类外观:
@EnableHystrix
@EnableEurekaClient
@SpringBootApplication
public class TableApp {
public static void main(String[] args) {
SpringApplication.run(TableApp.class, args);
}
}
如何解决此问题?
8条答案
按热度按时间uoifb46i1#
对于使用Sping Boot 2的用户,
hystrix.stream
端点已移至/actuator/hystrix.stream
。对我来说,这个网址工作:
是的,通过以下属性启用该执行器端点:
当然,您的项目中必须包含执行器依赖项。
iqxoj9l92#
Hystrix dashboard本身不能用于同时监控多个示例。您需要的是turbine +dashboard。简而言之,涡轮机是多个Hystrix指标流的聚合器。
示例的配置:
此处重要的是暴露hystix.stream执行器。此端点将被涡轮机用于读取指标。此外,不要忘记添加执行器启动器。
如果一切操作正确,
http://localhost:8080/actuator/hystrix.stream
端点应该可用。涡轮机配置如下所示:
在
appConfig
中,您应该指定要监视的服务名称。启动后,涡轮机机
localhost:8888/turbine.stream
将可用。您可以将此URL传递到 Jmeter 板,并监视为发现的示例的hystrix命令聚合的所有数据。
Github项目示例。
p.s.您使用的依赖项已过时。请检查maven repo
htrmnn0y3#
通过在**
application.properties
**中添加以下两个属性,我能够解决spring-boot-starter-parent
版本2.0.7.RELEASE
和spring-cloud-dependencies
版本Finchley.SR2
的此问题。lyfkaqu14#
最后,我找到了解决办法。
问题是控制器API必须通过HystrixCommand注解进行销售。
文档片段:
我在没有任何参数的情况下将其添加到所有Controller的方法中,如下所示:
而现在一切都像迷人的作品:
现在我明白了,我离它是如此之近。
of1yzvn45#
请确定您已将此项目加入application.properties中。
6za6bjd06#
我在最新版本的Spring-boot(2.3.3-XXX)和spring-cloud(Hoxton.SR7)中遇到了同样的问题,但是当我降级pom.xml文件中的版本时,它开始为我工作。
和
希望,这会很有帮助:)
fnvucqvd7#
1.将您的hystrix.stream网址更正为
http://localhost:8082/actuator/hystrix.stream
1.确保已将主机添加到hystrix-dashboard应用程序的配置文件中的
hystrix.dashboard.proxyStreamAllowList
,如下所示:a8jjtwal8#
查看github上的详细信息:https://github.com/HuiyingWang0108/hystrix-dashboard相关微服务:https://github.com/HuiyingWang0108/cloud-gatewayhttps://github.com/HuiyingWang0108/registry-service在我的例子中:像这样的应用程序:
步骤1:(1)修改pom.xml:
至
(2)添加到下面的应用程序中。yml
(3)然后启动应用程序,打开:
作品:
步骤2:(1)在pom.xml中添加以下内容
(2)在应用程序中添加以下内容.yml
(3)打开:显示: