【问题标题】:How to activate /turbine.stream endpoint in a standalone Turbine application如何在独立的 Turbine 应用程序中激活 /turbine.stream 端点
【发布时间】:2019-02-03 06:04:31
【问题描述】:

我正在尝试创建一个独立的应用程序来从其他应用程序收集 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);
    }

}

applicaiton.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> 

我为此创建了一个sample project。

【问题讨论】:

  • 调用 /turbine.stream 端点后会收到什么?

标签: spring spring-boot spring-cloud spring-cloud-netflix


【解决方案1】:

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

1) 您在 Hystrix Dashboard 中的流 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

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

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

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

如果一切顺利,您应该不会在浏览器上看到“[]”。

在集群端点上看到响应后,您现在可以在将仪表板指向涡轮应用程序时在仪表板上查看详细信息

【讨论】:

  • 我在Spring Cloud Sample 中使用 hystrix(client)、eureka-server 进行了尝试,我找不到任何暴露在我的涡轮机应用程序。
  • 我修复了这个示例,clusterConfig 应该是超级案例。
  • @hantsy 检查了你的 git,你的最后一次提交说你已经修复了它。是这样吗?
猜你喜欢
  • 1970-01-01
  • 2015-04-06
  • 1970-01-01
  • 2017-03-07
  • 1970-01-01
  • 1970-01-01
  • 2012-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多