如何在独立的 Turbine 应用程序中激活 /turbine.stream 端点

2024-02-23

我正在尝试创建一个独立的应用程序来从其他应用程序收集 Hystrix 流。但它并没有暴露/turbine.stream默认端点。我确信我的项目中缺少什么。

Spring Boot:2.0.4.RELEASE,Spring Cloud:Finchley.SR1

应用类:

@SpringBootApplication
@EnableDiscoveryClient
@EnableTurbine
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

application.yml的内容:

server:
  port: 8383
spring:
  application:
    name: hystrix-turbine

management:
  endpoints:
    web.exposure.include: '*'
applications: hystrix
turbine:
  aggregator:
    clusterConfig: ${applications}
  appConfig: ${applications}
#  instanceUrlSuffix.default: actuator/hystrix.stream

以及 Maven 依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies> 

我创建了一个示例项目 https://github.com/hantsy/spring-cloud-sample/tree/master/netflix-trubine为了这。


我建议您检查以下配置步骤:

1) Hystrix 仪表板中的流 URL 应该是:

http://localhost:{turbine app port}/turbine.stream?cluster={configured cluster in properties file}

该 url 应指向具有以下功能的应用程序的端口@EnableTurbine您的主类中的注释。

2) 检查您是否收到以下回复:

http://localhost:{client app port}/actuator/hystrix.stream

(使用您的浏览器)(这应该来自您已启用 hystrix 的应用程序@EnableCircuitBreaker)

如果您收到 ping,那么至少您的 hystrix 流是可以访问的。如果没有,请检查您是否有:org.springframework.boot:spring-boot-starter-actuator在你的客户端依赖项和 确保您在应用程序的 application.properties 文件中设置了以下属性@EnableCircuitBreaker在主类中:

management.endpoints.web.exposure.include= hystrix.stream, info, health

再次检查网址。

3)一旦您收到回复hystrix.stream,您现在可以在涡轮机应用程序属性文件上配置集群:

turbine:

      appConfig: {serviceId in lower case}
      aggregator:
        clusterConfig: {above serviceId in upper case} 

运行应用程序后,检查您是否已正确配置集群:

http://localhost:{turbine app port}/clusters

你不应该得到“[]如果一切顺利的话,在您的浏览器上显示“。

一旦您在集群端点上看到响应,当您将其指向涡轮机应用程序时,您现在就可以在仪表板上看到详细信息

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在独立的 Turbine 应用程序中激活 /turbine.stream 端点 的相关文章

随机推荐