2016-09-28 5 views
0

Hystrix Dashboardを初めて使用しています。私はHystrixでサンプルアプリケーションを作成しました。 Hystrixグラフ(コマンドメトリックストリーム)を見たいと思っています。しかし、私は以下のエラーが発生しています:Hystrix DashboardのSpring起動時の問題

Circuit: Unable to connect to Command Metric Stream 
Thread Pools: Loading... 

私はMavenでSTSを使用しています。

以下

が使用するコードです:私は含まれてい

単純なサーバーmicroserviceアプリケーション(ポート8085で実行している春のブートウェブ)

package hello; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.web.bind.annotation.RestController; 
import org.springframework.web.bind.annotation.RequestMapping; 

@RestController 
@SpringBootApplication 
public class BookstoreApplication { 

    @RequestMapping(value = "/recommended") 
    public String readingList(){ 
    return "Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)"; 
    } 

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

シンプルなクライアントmicroserviceアプリケーション(ポート8095で実行している春のブートウェブ) HystrixおよびWebと共にHystrixダッシュボードに依存するので、全てHystrix依存性は、上記のコードを実行することにより、クラスパス

package hello; 

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 
import org.springframework.stereotype.Service; 
import org.springframework.web.client.RestTemplate; 

import java.net.URI; 

@Service 
public class BookService { 

    private final RestTemplate restTemplate; 

    public BookService(RestTemplate rest) { 
    this.restTemplate = rest; 
    } 

    @HystrixCommand(fallbackMethod = "reliable") 
    public String readingList() { 
    URI uri = URI.create("http://localhost:8090/recommended"); 

    return this.restTemplate.getForObject(uri, String.class); 
    } 

    public String reliable() { 
    return "Cloud Native Java (O'Reilly)"; 
    } 

} 


package hello; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.boot.web.client.RestTemplateBuilder; 
import org.springframework.context.annotation.Bean; 
import org.springframework.web.bind.annotation.RestController; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 
import org.springframework.web.client.RestTemplate; 

@EnableHystrixDashboard 
@EnableHystrix 
@EnableCircuitBreaker 
@RestController 
@SpringBootApplication 
public class ReadingApplication { 

    @Autowired 
    private BookService bookService; 

    @Bean 
    public RestTemplate rest(RestTemplateBuilder builder) { 
    return builder.build(); 
    } 

    @RequestMapping("/to-read") 
    public String toRead() { 
    return bookService.readingList(); 
    } 

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

ていますhystrixは正常に動作しています.BooKStoreApplicationがダウンしているときは、フォールバック方式になります。

両方のURLが正常に動作しています。 ノーマルケース:

http://localhost:8085/recommended 
Output: Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt) 

http://localhost:8095/to-read 
Output: Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt) 


When BookStoreApplication is down (http://localhost:8085/recommended) accessing http://localhost:8095/to-read returns "Cloud Native Java (O'Reilly)" as expected. 

しかし、私はこのURL http://localhost:8095/hystrixを起動しようとしたとき、私はHystrixのDashBoardページを取得し、ストリーム値を求めています。

私はhttp://localhost:8095/またはhttp://localhost:8095/to-read与えてみました、そして「モニターストリーム」をクリックすると、それはエラーで次のページに行くされています

Circuit: Unable to connect to Command Metric Stream 
Thread Pools: Loading... 

答えて

2

私は同じことを経験しました。主な問題は、私は私のmaven pomにアクチュエータの依存性がないということでした。だから私はヒステリックストリームを取得できませんでした。

  1. スプリングブートアクチュエータを含みます。
  2. localhost:8085/healthが動作しているかどうかを確認してください。
  3. Hystrix Dashboardでlocalhost:8085/hystrix.streamの値をストリームに入力してみます。
  4. サービスを数回実行します。 - >ダッシュボードには、監視対象のメソッド/コマンドが表示されます。
関連する問題