cloud+eureka+fegin+ribbon+hystrix+rabbitMQ+sleuth+zipkin+config+dashboard+zuul大合集开发(五)之dashboardl集成

当一个集群的服务非常多的时候,他的性能等不一定就非常好,各个服务的性能情况等不好把控,因此spring cloud可以集成dashboard框架,对各个服务进行一定的监控,查看其性能等数据,下面给大家简单介绍下dashboard的搭建,特别简单

这个监控服务你可以单独建一个也可以建在你的父工程下,因为其和其他工程几乎没有关联,所以随意,本人为工程整体性就建在前几篇介绍的父工程下

在第一篇的工程下新建名称为server-dashboard的子工程

在pom文件里面添加以下依赖

<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>Greenwich.RELEASE</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

  <dependencies>
	    <dependency>
	      <groupId>junit</groupId>
	      <artifactId>junit</artifactId>
	      <version>4.11</version>
	      <scope>test</scope>
	    </dependency>
	    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.2.RELEASE</version>
        </dependency>
	    <dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
			<version>1.4.6.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-hystrix</artifactId>
			<version>1.4.6.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>com.netflix.hystrix</groupId>
			<artifactId>hystrix-javanica</artifactId>
			<version>RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
			<version>2.1.2.RELEASE</version>
		</dependency>
  </dependencies>

编写启动类,让其已8083端口号启动:

package org.server.dashboard;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

/**
 * Hello world!
 *
 */
@SpringBootApplication
@EnableHystrixDashboard
public class App 
{
	public static void main(String[] args) {
		// 设置启动的服务器端口
		new SpringApplicationBuilder(App.class).properties(
				"server.port=8083").run(args);
	}
}

在被监控的服务的启动类上面加注解@EnableCircuitBreaker,本人以前几篇所描述的服务调用者为例:

然后依次启动前面几篇中所写的服务注册中心,服务提供者,服务调用者,网关,以及本篇的监控服务,然后访问localhost:8083/hystrix可以看到如下页面

看到该页面说明监控服务启动成功,接下来在该页面第一个输入框输入被监控的服务地址http://localhost:9001/hystrix.stream,注意:此处所写服务地址必须是在启动类加了@EnableCircuitBreaker注解的服务,不然会看不到效果,本人输入的是端口为9001的服务调用者服务,如下

然后点击最下方的按钮则可看到如下界面 

可以看到此时没有任何图形等输出,这是因为被监控的服务此时尚未被调用,还没有产生数据,这时可以在另外一个页面访问前几篇配置好的网关项目地址localhost:8080/testZuul/router,再回到监控页面,可以看到有数据图绘出

若看到如上界面,则说明监控成功了,不过遗憾的是此种形式的监控框架在spring boot2.0后貌似已经被官方遗弃,不在维护,说明该框架还是有一定的鸡肋,但也不影响使用。此篇文章也就不做过多的介绍了。因为后面也将引入另外一个类似于监控框架的sleuth+zipkin集成,主要是对日志进行跟踪,查看其调用情况等。不过在介绍它之前我们先看下rabbitMQ的集成;

 

下一篇将介绍rabbitMQ的集成。

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值