Spring Cloud Turbine 空流
Posted
技术标签:
【中文标题】Spring Cloud Turbine 空流【英文标题】:Spring Cloud Turbine empty stream 【发布时间】:2015-05-12 11:56:17 【问题描述】:我有一个作为涡轮服务器和 Hystrix 仪表板的 Spring Cloud 应用程序。它有一个 Eureka 客户端,仪表板正常运行,可以看到一个单独的 Hystrix 流,但我在涡轮流中没有得到任何东西。
这是application.yml:
eureka:
client:
serviceUrl:
defaultZone: $vcap.services.eureka-service.credentials.uri:http://10.12.2.99:8761/eureka/
turbine:
aggregator:
clusterConfig: ITEMS-SERVICE
appConfig: items-service
如果我在 Turbine/dashboard 应用程序启动时查看日志,它看起来好像发现我的 Hystrix 服务正常:
2015-03-10 14:45:35.256 INFO 1383 --- [ Timer-0] o.s.c.n.turbine.EurekaInstanceDiscovery : Fetching instance list for apps: [items-service]
2015-03-10 14:45:35.257 INFO 1383 --- [ Timer-0] o.s.c.n.turbine.EurekaInstanceDiscovery : Fetching instances for app: items-service
2015-03-10 14:45:35.257 INFO 1383 --- [ Timer-0] o.s.c.n.turbine.EurekaInstanceDiscovery : Received instance list for app: items-service, size=2
2015-03-10 14:45:35.264 INFO 1383 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Retrieved hosts from InstanceDiscovery: 2
2015-03-10 14:45:35.265 INFO 1383 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Found hosts that have been previously terminated: 0
2015-03-10 14:45:35.265 INFO 1383 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Hosts up:2, hosts down: 0
2015-03-10 14:45:35.270 INFO 1383 --- [ Timer-0] c.n.t.monitor.instance.InstanceMonitor : Url for host: http://nf-app1:8080/hystrix.stream ITEMS-SERVICE
2015-03-10 14:45:35.270 INFO 1383 --- [ Timer-0] c.n.t.handler.TurbineDataDispatcher :
Just added and starting handler tuple: ITEMS-SERVICE_agg_aggClusterEventHandler
2015-03-10 14:45:35.271 INFO 1383 --- [ Timer-0] c.n.turbine.data.AggDataFromCluster : Per handler dispacher started for: ITEMS-SERVICE_agg_aggClusterEventHandler
2015-03-10 14:45:35.273 INFO 1383 --- [ Timer-0] c.n.t.monitor.instance.InstanceMonitor : Url for host: http://nf-app2:8080/hystrix.stream ITEMS-SERVICE
如果我在
处遇到涡轮流http://localhost:8080/turbine.stream?cluster=ITEMS-SERVICE
我明白了:
: ping
data: "timestamp":1426018670641,"name":"meta","reportingHostsLast10Seconds":0,"type":"meta"
: ping
data: "timestamp":1426018673643,"name":"meta","reportingHostsLast10Seconds":0,"type":"meta"
: ping
data: "timestamp":1426018676645,"name":"meta","reportingHostsLast10Seconds":0,"type":"meta"
当我查看涡轮机/仪表板日志时,我没有看到任何错误:
2015-03-10 14:48:33.804 INFO 1383 --- [nio-8080-exec-1] c.n.t.s.servlet.TurbineStreamServlet : FilterCriteria: []
2015-03-10 14:48:33.804 INFO 1383 --- [nio-8080-exec-1] c.n.t.s.servlet.TurbineStreamServlet : StatsType filters: []
2015-03-10 14:48:33.808 INFO 1383 --- [nio-8080-exec-1] c.n.t.s.TurbineStreamingConnection : Relevance config: []
2015-03-10 14:48:33.808 INFO 1383 --- [nio-8080-exec-1] c.n.t.s.TurbineStreamingConnection : Relevance metrics config:
2015-03-10 14:48:33.809 INFO 1383 --- [nio-8080-exec-1] c.n.t.monitor.cluster.ClusterMonitor : Registering event handler for cluster monitor: StreamingHandler_f1b7fc33-d0ed-4206-9976-fd4b2347bdd5
2015-03-10 14:48:33.809 INFO 1383 --- [nio-8080-exec-1] c.n.t.handler.TurbineDataDispatcher :
Just added and starting handler tuple: StreamingHandler_f1b7fc33-d0ed-4206-9976-fd4b2347bdd5
2015-03-10 14:48:33.809 INFO 1383 --- [nio-8080-exec-1] c.n.turbine.data.AggDataFromCluster : Per handler dispacher started for: StreamingHandler_f1b7fc33-d0ed-4206-9976-fd4b2347bdd5
2015-03-10 14:48:33.809 INFO 1383 --- [nio-8080-exec-1] c.n.t.monitor.cluster.ClusterMonitor : All event handlers for cluster monitor: [StaticListener_For_Aggregator, StreamingHandler_f1b7fc33-d0ed-4206-9976-fd4b2347bdd5]
2015-03-10 14:48:33.809 INFO 1383 --- [nio-8080-exec-1] c.n.t.monitor.cluster.ClusterMonitor : Starting up the cluster monitor for ITEMS-SERVICE_agg
2015-03-10 14:48:35.265 INFO 1383 --- [ Timer-0] o.s.c.n.turbine.EurekaInstanceDiscovery : Fetching instance list for apps: [items-service]
2015-03-10 14:48:35.266 INFO 1383 --- [ Timer-0] o.s.c.n.turbine.EurekaInstanceDiscovery : Fetching instances for app: items-service
2015-03-10 14:48:35.266 INFO 1383 --- [ Timer-0] o.s.c.n.turbine.EurekaInstanceDiscovery : Received instance list for app: items-service, size=2
2015-03-10 14:48:35.266 INFO 1383 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Retrieved hosts from InstanceDiscovery: 2
2015-03-10 14:48:35.266 INFO 1383 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Found hosts that have been previously terminated: 0
2015-03-10 14:48:35.267 INFO 1383 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Hosts up:2, hosts down: 0
如果我直接或通过仪表板点击其中一个项目流(例如http://nf-app1:8080/hystrix.stream),我将获得有效的 Hystrix 数据。
看起来 Turbine 应用程序正在通过 Eureka 找到这两个项目服务,并且它们的 Hystrix 流端点是有效的并且可以工作,所以我无法弄清楚为什么 Turbine 流是空的。
【问题讨论】:
您看到的数据并不是“无效”的,我会说。看起来这些电路从未在涡轮机指向的应用程序实例中使用。也许您需要稍微弯曲它们以使它们发送一些数据?或者,您的 nf-app1:8080/hystrix.stream 实验可能指向不同的物理实例? 感谢您的回复戴夫。 nf-app1 和 nf-app2 是单个物理实例,我已经对它们进行了足够的打击,以使它们各自的 hystrix.stream 端点返回完整数据并分别成功地显示在 hystrix 仪表板上。我可以在尝试使用 Turbine 端点之前和之后从 nf1 和 2 hystrix.streams 获取完整数据,该端点始终返回与前面所示相同类型的响应。 也许集群名称中的“-”(连字符)有问题(URL 编码?)?它对我有用,但我没有使用任何非 alpha 字符。 我尝试将 clusterConfig 更改为ITEMSERVICE
,结果相同。我对 Spring cloud docs 有点困惑,因为它说:“从 eureka 返回的值是大写的,因此如果有一个在 Eureka 注册的名为“customers”的应用程序,我们希望这个示例能够工作:turbine:aggregator:clusterConfig:CUSTOMERS appConfig:客户 - 看起来文档似乎在说集群名称应该与 Eureka 名称匹配,但这只是建议的约定吗?
当我读到它时我也很困惑。我用来测试的样本是这个:github.com/spring-cloud-samples/tests/tree/master/turbine。它适用于我(集群名称与服务名称相同),您能否验证它是否适用于您?
【参考方案1】:
问题是运行 Turbine 的机器未与运行 Hysterix 服务的机器进行时间同步。 This Answer 在另一个 Turbine 问题上表示默认情况下 Turbine 将忽略“旧”事件。我尝试在我的 application.yml 中禁用 turbine.InstanceMonitor.eventStream.skipLineLogic
并且一切都开始工作了。
【讨论】:
以上是关于Spring Cloud Turbine 空流的主要内容,如果未能解决你的问题,请参考以下文章
spring cloud:hystrix-dashboard-turbine
spring cloud 熔断面板 聚合熔断 turbine
hystrix.stream、management.port 和 Spring Cloud Turbine