一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - Spring Cloud之服務(wù)監(jiān)控turbine的示例

Spring Cloud之服務(wù)監(jiān)控turbine的示例

2021-04-25 11:13冰清雪酷 Java教程

這篇文章主要介紹了Spring Cloud之服務(wù)監(jiān)控turbine的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

turbine是聚合服務(wù)器發(fā)送事件流數(shù)據(jù)的一個(gè)工具,hystrix的監(jiān)控中,只能監(jiān)控單個(gè)節(jié)點(diǎn),實(shí)際生產(chǎn)中都為集群,因此可以通過turbine來監(jiān)控集群下hystrix的metrics情況,通過eureka來發(fā)現(xiàn)hystrix服務(wù)。

新建turbine項(xiàng)目

turbineapplication.java

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package turbine;
import org.springframework.boot.springapplication;
import org.springframework.boot.autoconfigure.springbootapplication;
import org.springframework.cloud.netflix.hystrix.enablehystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.enablehystrixdashboard;
import org.springframework.cloud.netflix.turbine.enableturbine;
/**
 * created by sai.luo on 2017/4/26.
 */
@springbootapplication
@enableturbine
@enablehystrix
@enablehystrixdashboard
public class turbineapplication{
 public static void main(string[] args) {
  springapplication.run(turbineapplication.class,args);
 }
}

pom.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/pom/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
   xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelversion>4.0.0</modelversion>
 
 <artifactid>turbine</artifactid>
 <properties>
  <project.build.sourceencoding>utf-8</project.build.sourceencoding>
  <java.version>1.8</java.version>
 </properties>
 
 <parent>
  <groupid>org.springframework.boot</groupid>
  <artifactid>spring-boot-starter-parent</artifactid>
  <version>1.5.2.release</version>
  <relativepath/> <!-- lookup parent from repository -->
 </parent>
 
 <dependencies>
  <!-- hystrix依賴 -->
  <dependency>
   <groupid>org.springframework.cloud</groupid>
   <artifactid>spring-cloud-starter-hystrix</artifactid>
  </dependency>
  <dependency>
   <groupid>org.springframework.cloud</groupid>
   <artifactid>spring-cloud-starter-hystrix-dashboard</artifactid>
  </dependency>
  <!-- turnbine依賴 -->
  <dependency>
   <groupid>org.springframework.cloud</groupid>
   <artifactid>spring-cloud-starter-turbine</artifactid>
  </dependency>
 </dependencies>
 <dependencymanagement>
  <dependencies>
   <dependency>
    <groupid>org.springframework.cloud</groupid>
    <artifactid>spring-cloud-dependencies</artifactid>
    <version>camden.sr5</version>
    <type>pom</type>
    <scope>import</scope>
   </dependency>
  </dependencies>
 </dependencymanagement>
 
 <build>
  <plugins>
   <plugin>
    <groupid>org.springframework.boot</groupid>
    <artifactid>spring-boot-maven-plugin</artifactid>
   </plugin>
  </plugins>
 </build>
</project>

application.yml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
spring:
 application:
 name: turbine
server:
 port: 8000
turbine:
 app-config: hello,helloclient ##需要監(jiān)控的服務(wù)名
 aggregator:
 clusterconfig: main ##需要監(jiān)控的服務(wù)集群名
 clusternameexpression: metadata['cluster']
 
eureka:
 instance:
 preferipaddress: true
 statuspageurlpath: /info.html
 client:
 serviceurl:
  defaultzone: http://localhost:8761/eureka/

啟動服務(wù)

helloserviceeureka 項(xiàng)目 appliation.yml 增加集群配置

更改為

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
spring:
 application:
 name: hello
 
server:
 port: 9001
 
eureka:
 instance:
 lease-renewal-interval-in-seconds: 3
 lease-expiration-duration-in-seconds: 5
 metadata-map:
  cluster: main
 client:
 serviceurl:
  defaultzone: http://localhost:8761/eureka/
 registry-fetch-interval-seconds: 3
 
logging:
 level:
 com:
  netflix:
  eureka: off
  discovery: off

pom.xml增加hystrix依賴包

?
1
2
3
4
<dependency>
 <groupid>org.springframework.cloud</groupid>
 <artifactid>spring-cloud-starter-hystrix</artifactid>
</dependency>

同理ribboneureka 項(xiàng)目 application.yml 增加集群配置

更改后如下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
spring:
 application:
 name: helloclient
 
server:
 port: 20000
 
eureka:
 instance:
 lease-renewal-interval-in-seconds: 3
 lease-expiration-duration-in-seconds: 5
 metadata-map:
  cluster: main
 client:
 serviceurl:
  defaultzone: http://localhost:8761/eureka/
 registry-fetch-interval-seconds: 3
 
logging:
 level:
 com:
  netflix:
  eureka: off
  discovery: off

pom.xml增加hystrix依賴包

ribboneurekaapplication.java 增加注解

?
1
@enablehystrix

啟動項(xiàng)目

訪問 localhost:8000/hystrixx 可以看到頁面

注: turbine只能監(jiān)控hystrix服務(wù),不是hystrix服務(wù),不能監(jiān)控,如 hello這個(gè)服務(wù)雖然配置了集群,但是沒有使用hystrix,所以不會受監(jiān)控。

項(xiàng)目地址 https://github.com/luosai001/spring-cloud-sample/tree/master

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://blog.csdn.net/luosai19910103/article/details/70820904

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美成人一区二区 | 国产欧美日韩免费一区二区 | 午夜爱 | 国产精品欧美日韩一区二区 | 国产亚洲精品美女久久久 | 91大神第九部红酒气质女 | 男人狂躁女人下面狂叫图片 | 极品妖艳许清赵丽全文免费阅读 | 国产精品久久久久久久久久久搜索 | 99精品热视频 | 国产亚洲成归v人片在线观看 | 成人网免费视频 | 日韩国产欧美成人一区二区影院 | 果冻传媒九一制片厂网站 | 成年人视频免费在线观看 | 网址在线观看你懂我意思吧免费的 | 日本高清在线播放一区二区三区 | 亚洲激情综合 | 国产一区二区三区欧美精品 | 国产精品久久国产三级国电话系列 | 色先锋影音先锋 | 特级夫妻大片免费在线播放 | 91久久夜色精品国产九色 | 2020最新韩国理论三级0k | 2020国产精品亚洲综合网 | 久久免费看少妇高潮A片JA | 亚洲精品免费在线观看 | 女人扒开下面让男人桶爽视频 | 亚洲AV久久久噜噜噜久久 | 亚洲黄色小视频 | 法国老妇性xx在线播放 | 亚洲一级片在线播放 | 极品在线 | 特黄特a级特别特级特毛片 特黄a级三级三级野战 | 日本在线观看视频网站 | 强迫高h| 含羞草传媒一天免费看下 | 91嫩草私人成人亚洲影院 | 视频一区二区三区在线 | 国产精品视频久 | 98成人网|