07 使用admin进行服务监控

springcloud中的admin模块用于服务监控,本节将阐述该模块。

1、环境约束

  • win10 64为操作系统
  • idea2018.1.5
  • maven-3.0.5
  • jdk-8u162-windows-x64

2、前提约束

3、操作步骤

3.1 创建admin-server

  • 创建一个springcloud项目,包括springweb,eureka client,admin server,包括以下关键依赖:
      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
        </dependency>

注意:springboot的版本是2.1.1.RELEASE,springcloud的版本是Greenwich.SR1,admin 的版本是2.1.2

  • 在主启动类上除@SpringBootApplication之外加入以下注解:
@EnableAdminServer
@EnableEurekaClient
  • 修改appliation.yml
server:
  port: 8001
spring:
  application:
    name: admin-server
eureka:
  client:
    service-url:
      defaultZone: http://localhost:7561/eureka/
management:
  endpoint:
    health:
      show-details: always
  endpoints:
    web:
      exposure:
        include: health,info

3.2 创建admin-client

  • 创建一个springcloud项目,包括springweb,eureka client,admin client,包括以下关键依赖:
       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

注意:springboot的版本是2.1.1.RELEASE,springcloud的版本是Greenwich.SR1,admin 的版本是2.1.2

  • 修改application.yml,内容如下:
server:
  port: 8002
spring:
  application:
    name: admin-client
  boot:
    admin:
      client:
        url: http://localhost:8001

eureka:
  client:
    service-url:
      defaultZone: http://localhost:7561/eureka/

3.3 测试

依次启动eureka,admin server,admin client,在浏览器中访问http://localhost:8001/#/wallboard,出现以下监控界面:

 
16204070-f702abfccd9ea853.png
wallboard


以上就是使用admin进行的服务监控。

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值