1

Spring Cloud Netflix のガイドに従ってTurbine を構成しました。2 つのマイクロサービスで Hystrix を有効にした後、/hystrix.stream エンドポイントが正しい出力を生成することを確認しました。

hystrix ダッシュボード プロジェクトで、すべてのサービスの集計結果を取得するように Turbine を構成しました。しかし、私が得るのは次の連続です:

: ping
data: {"reportingHostsLast10Seconds":0,"name":"meta","type":"meta","timestamp":1448552456486}

これは私の設定です:

HystrixDashboard + タービン アプリケーション:

@EnableHystrixDashboard
@EnableTurbine
@SpringBootApplication
public class HystrixDashboardApplication {

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

HystrixDashboard + タービン application.yml:

spring:
  application:
    name: hystrix-dashboard

server:
  port: 10000

turbine:
  appConfig: random-story-microservice,storyteller-api
  instanceUrlSuffix: /hystrix.stream

logging:
  level:
    com.netflix.turbine: 'TRACE'

アップデート

kreel の指示に従って、Turbine を次のように構成しました。

turbine:
  appConfig: random-story-microservice,storyteller-api
  instanceUrlSuffix: /hystrix.stream
  clusterNameExpression: new String("default")

例外で失敗することはもうありません。ログを見ると、Turbine が 2 つの候補ホスト/マイクロサービスを見つけていることがわかります。

[        Timer-0] c.n.t.discovery.InstanceObservable       : Retrieved hosts from InstanceDiscovery: 2

ただし、最終的に登録されるのはそのうちの 1 つだけです。ホストの 1 つだけが追加されます。これInstanceObservable.run()は、ハッシュコードが同じであるため、newState.hostsUp に追加されたときに同じと見なされるためです。com.netflix.turbine.discovery.Instanceハッシュコードは、ホスト名 (どちらの場合も「myhost」) とクラスター (「デフォルト」) に基づいて計算されます。

// set the current state
            for(Instance host: newList) {
                if(host.isUp()) {
                    newState.hostsUp.add(host);
                } else {
                    newState.hostsDown.add(host);
                }
            }

同じホストが 2 つの異なるマイクロサービスを提供している場合、どうすればよいでしょうか? この場合、最初のインスタンスのみが登録されます。

4

3 に答える 3

0

私は答えを持っていると思いますが、最初に、確かに、なぜ「デフォルト」を期待していますか?

于 2015-11-26T16:01:13.920 に答える
0

実際、あなたはドキュメントを誤解していると思います:

The configuration key turbine.appConfig is a list of eureka serviceIds that turbine will use to lookup instances. The turbine stream is then used in the Hystrix dashboard using a url that looks like: http://my.turbine.sever:8080/turbine.stream?cluster=<CLUSTERNAME>; (the cluster parameter can be omitted if the name is "default"). The cluster parameter must match an entry in turbine.aggregator.clusterConfig. Values returned from eureka are uppercase, thus we expect this example to work if there is an app registered with Eureka called "customers":

turbine:
  aggregator:
    clusterConfig: CUSTOMERS
  appConfig: customers

あなたの場合:

turbine:
  aggregator:
    clusterConfig: MY_CLUSTER
  appConfig: random-story-microservice,storyteller-api

そのため、「random-story-microservice,storyteller-api」を大文字で返します。

于 2015-11-26T16:20:54.660 に答える