Turbine(基于OpenFeign)
<h1>概述</h1>
<h3>Hystrix-Dashboard</h3>
<pre><code>Hystrix Dashboard,它可以通过服务地址来实时监控Hystrix的各项指标信息。通过Hystrix Dashboard反馈的实时信息,可以帮助我们快速发现系统中存在的问题。</code></pre>
<h3>Hystrix-Dashboard与Turbine</h3>
<pre><code> 由于#Hystrix-Dashboard只能通过服务地址监控单个服务的Hystrix的各项指标信息,所以引入Turbine,它可以通过服务名称,监控该服务名称汇总起来的Hystrix各项指标信息</code></pre>
<h3>OpenFeign与Turbine</h3>
<pre><code> OpenFeign已集成Turbine</code></pre>
<p><br></p>
<h1>环境安装</h1>
<h3>监控方</h3>
<h4>a.引入maven依赖</h4>
<pre><code> <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency> </code></pre>
<h4>b.启动类上加上注解</h4>
<pre><code> @EnableHystrixDashboard
@EnableTurbine
@EnableDiscoveryClient</code></pre>
<h4>c.application.yml</h4>
<pre><code> eureka:
client:
service-url:
defaultZone: http://nisbos:nisbos@localhost:1111/eureka/
turbine:
#被监控的服务名
app-config: NISBOS-FEIGN-PROVIDER
#默认集群名称
cluster-name-expression: new String("default")
注意被监控的hystrix服务连接的eureka地址和这边的eureka地址要一致</code></pre>
<h3>被监控方</h3>
<h4>a.application.yml</h4>
<pre><code>#放开权限,可以被hystrix dashboard监控到
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS</code></pre>
<p><br></p>
<h1>场景预览</h1>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/7955d0576aa4bb7eb2a02b4fbb9cefd1?showdoc=.jpg" alt="" /></p>
<pre><code>通过上图可以看到,Hystrix Dashboard+Turbine可以通过可视化界面监控到使用hystrix超时熔断、错误熔断等请求</code></pre>
<p><br></p>
<h1>快速入门</h1>
<h3>启动本地服务,监控nisbos-feign-provider项目为例</h3>
<h5>a.启动服务</h5>
<pre><code>启动nisbos-feign-provider项目
启动nisbos-hystrix-dashboard项目</code></pre>
<h5>b.访问监控方</h5>
<pre><code>打开 http://localhost:2101/hystrix 输入 http://localhost:2101/turbine.stream ,点击 Monitor Stream</code></pre>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/8ecaeaee858d2ac4ce3845d498a065f8?showdoc=.jpg" alt="" /></p>
<h5>c.访问被监控方使用hystrix超时熔断的服务</h5>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/06005d1756bcc6e36d0d4579cff83342?showdoc=.jpg" alt="" /></p>
<h5>d.查看监控方看板</h5>
<p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/2e75065a6c7e72c7d8d6db150e22d36a?showdoc=.jpg" alt="" /></p>