日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring Cloud【Finchley】-12使用Hystrix Dashboard实现Hystrix数据的可视化监控

發(fā)布時間:2025/3/21 javascript 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Cloud【Finchley】-12使用Hystrix Dashboard实现Hystrix数据的可视化监控 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 概述
  • Hystrix Dashboard
    • Step 1 新建項目
    • Step2 增加maven依賴
    • Step3 啟動類增加注解@EnableHystrixDashboard
    • Step4 配置文件application.yml
    • Step5 啟動微服務(wù)
    • Step6 測試
  • 代碼

概述

Spring Cloud【Finchley】-11Feign項目整合Hystrix監(jiān)控中,我們通過 http://ip:port/actuator/hystrix.stream 的形式來查看到的Hystrix的數(shù)據(jù)都是文本形式,可讀性非常差。 好在Spring Cloud為我們提供了Hystrix Dashboard,來看下如何使用吧。

官方文檔: https://cloud.spring.io/spring-cloud-static/Finchley.SR2/single/spring-cloud.html#_circuit_breaker_hystrix_dashboard


Hystrix Dashboard

為了方便統(tǒng)一管理,這里的例子我們也將Hystrix Dashboard這個微服務(wù)注冊到Eureka上,當然了也可以不注冊。


Step 1 新建項目

我們在父工程的maven上右鍵新建module , 起名為 micorservice-hystrix-dashboard

如下


Step2 增加maven依賴

<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-hystrix-dashboard</artifactId></dependency>

我們打算注冊到Eureka上,所以也需要添加spring-cloud-starter-netflix-eureka-client


Step3 啟動類增加注解@EnableHystrixDashboard

同時我們也打算注冊到Eureka上,所以也需要添加@EnableDiscoveryClient注解

package com.artisan.micorservice;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;@SpringBootApplication @EnableDiscoveryClient @EnableHystrixDashboard public class MicorserviceMovieRibbonHystrixDashboard {public static void main(String[] args) {SpringApplication.run(MicorserviceMovieRibbonHystrixDashboard.class, args);} }

Step4 配置文件application.yml

server:port: 8888spring:application:name: micorservice-hystrix-dashboard#eureka eureka:client:service-url:defaultZone: http://artisan:artisan123@localhost:8761/eurekainstance:prefer-ip-address: true # 起碼點擊后 會看到ip信息instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}

Step5 啟動微服務(wù)

因為我們注冊到了Eureka上,所以需要先啟動microservice-discovery-eureka,然后再啟動該服務(wù),啟動成功后,訪問 http://localhost:8888/hystrix

Step6 測試

  • 繼續(xù)啟動服務(wù)提供者微服務(wù) micorservice-provider-user,
  • 然后啟動整合了Hystrix的消費者微服務(wù) micorservice-consumer-movie-ribbon-hystrix 和 micorservice-consumer-movie-fegin-hystrix

到Eureka上看下注冊的服務(wù)列表

micorservice-consumer-movie-fegin-hystrix 對應(yīng)的hystrix url為:http://localhost:7901/actuator/hystrix.stream

micorservice-consumer-movie-ribbon-hystrix 對應(yīng)的hystrix url為:
http://localhost:7902/actuator/hystrix.stream

分別輸入url和自定義的title

點擊Monitor Stream 進入, 一直處于loading狀態(tài)

是因為還沒有觸發(fā)hystrix,我們來調(diào)用這倆微服務(wù)提供的對外接口

訪問下 http://localhost:7901/movie/1 觸發(fā)hystrix收集信息,多訪問幾次,信息如下

訪問下 http://localhost:7902/movie/2 觸發(fā)hystrix收集信息 ,多訪問幾次

以上就實現(xiàn)了通過Dashboard 對單個節(jié)點的微服務(wù)進行近乎實時的可視化監(jiān)控。

上圖中的參數(shù)說明參考官網(wǎng) https://github.com/Netflix-Skunkworks/hystrix-dashboard/wiki:


代碼

https://github.com/yangshangwei/SpringCloudMaster/tree/master/micorservice-hystrix-dashboard

總結(jié)

以上是生活随笔為你收集整理的Spring Cloud【Finchley】-12使用Hystrix Dashboard实现Hystrix数据的可视化监控的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。