spring-boot admin的github地址:https://github.com/codecentric/spring-boot-admin

本文基于SpringCloud的环境和配置上增加配置信息,而不是从0开始的配置。

一、搭建admin服务端

1、引入pom

<properties>
<spring-boot-admin-starter-client.version>1.5.6</spring-boot-admin-starter-client.version>
<spring-boot-admin-serve.version>1.5.7</spring-boot-admin-serve.version>
<spring-boot-admin-serve-ui.version>1.5.7</spring-boot-admin-serve-ui.version>
</properties> <dependencies>
<!-- 增加admin server 和 ui支持 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>${spring-boot-admin-serve.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>${spring-boot-admin-serve-ui.version}</version>
</dependency> <!-- 增加对hystrix的UI支持,需要服务依赖了hystrix -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-hystrix</artifactId>
<version>1.5.7</version>
</dependency>
<!-- 增加对turbine的集成支持,需要指定相关turbine参数信息 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-turbine</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>

2、application.properties

# 应用名称
# 这个变量必须写在这里,因为项目启动的时候需要记录日志文件,如果写在git上讲导致生成bootstrap.log和springAppName_IS_UNDEFINED.log
spring.application.name=crm-admin-server
# 服务端口
server.port= spring.profiles.active=local
# 非本地的启动,注册中心采用启动参数传入,本地测试也在启动参数中注入
eureka.client.serviceUrl.defaultZone=http://127.0.0.1:/eureka/ eureka.instance.lease-renewal-interval-in-seconds=
eureka.instance.lease-expiration-duration-in-seconds=
eureka.instance.preferIpAddress=true
eureka.client.registryFetchIntervalSeconds= #禁用管理的鉴权
management.security.enabled=false
#开启shutdown
endpoints.shutdown.enabled=true
#禁用shutdown的鉴权
endpoints.shutdown.sensitive=false
#开启重启支持
endpoints.restart.enabled=true #admin管理的端点(actuator)
spring.boot.admin.routes.endpoints=env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream
# turbine服务id
spring.boot.admin.turbine.location=crm-turbine

3、Main方法

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import de.codecentric.boot.admin.config.EnableAdminServer; @SpringBootApplication
@EnableDiscoveryClient
@EnableAdminServer
public class CrmAdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(CrmAdminServerApplication.class, args);
}
}

二、admin客户端

1、引用pom

对于SpringCloud项目来说会默认依赖actuator,只要再加入如下依赖即可

<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>

当然,简单省事的方案就是直接引用spring-boot-admin-starter-client

<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>

2、application.properties

# 禁用actuator管理端鉴权
management.security.enabled=false
# 启用shutdown host:port/shutdown
endpoints.shutdown.enabled=true
# 禁用密码验证
endpoints.shutdown.sensitive=false
# 开启重启支持
endpoints.restart.enabled=true # admin的log选项卡用
logging.file=/data/logs/crm/${spring.application.name}.log

3、logback-spring.xml中增加对JMX的支持

<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" /> <jmxConfigurator/>

这样做的好处是可以在admin的ui界面动态改变某些的日志级别。

三、访问Spring Boot Admin UI界面

Admin Server的配置文件:

spring.boot.admin.routes.endpoints=env,metrics,dump,jolokia,info,configprops,trace,logfile,restart,shutdown,refresh,heapdump,loggers,auditevents,hystrix.stream
# turbine服务id
spring.boot.admin.turbine.location=crm-admin-server spring.boot.admin.turbine.clusters=default
turbine.clusterNameExpression=new String("default")
#设置需要监控的serviceId
turbine.app-config=crm-security-rest,crm-security-service,crm-basic-rest,crm-basic-service,crm-customer-open-service,crm-customer-rest,crm-customer-service,crm-report-rest,crm-report-service,crm-gateway,crm-inside-gateway
#同一主机上的服务通过host和port的组合来进行区分
turbine.combine-host-port=true spring.mail.host=smtp.exmail.qq.com
spring.mail.username=xx@qq.com
spring.mail.password=xxxxxx spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.properties.mail.smtp.socket.factory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socket.factory.fallback=false
spring.mail.properties.mail.smtp.port=
spring.mail.properties.mail.transport.protocol=smtp #需要忽略的状态改变通知,逗号分隔,例如不通知离线到上线的状态,则填写为OFFLINE:UP
#spring.boot.admin.notify.mail.ignore-changes=
#接收通知的邮箱地址,逗号分隔
spring.boot.admin.notify.mail.to=yangzhilong@qq.com
#需要抄送的邮箱地址,逗号分隔
#spring.boot.admin.notify.mail.cc=test1@qq.com
#邮件发送者,大部分情况与登录名相同
spring.boot.admin.notify.mail.from=${spring.mail.username}
#邮件主题,默认是:#{application.name} (#{application.id}) is #{to.status}
spring.boot.admin.notify.mail.subject=${spring.profiles.active} profile's #{application.name} (#{application.id}) is #{to.status}
#邮件内容,默认是:#{application.name} (#{application.id})\nstatus changed from #{from.status} to #{to.status}\n\n#{application.healthUrl}
spring.boot.admin.notify.mail.text=${spring.profiles.active} profile's #{application.name} (#{application.id})\nstatus changed from #{from.status} to #{to.status}
#Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.默认值:"UNKNOWN:UP"
#spring.boot.admin.notify.mail.ignore-changes=

使用SpringBoot Admin监控SpringCloud微服务的更多相关文章

  1. 使用springboot Admin 2.0.6版本 集成监控springcloud微服务应用

    一 新建 添加依赖 <dependencies> <dependency> <groupId>de.codecentric</groupId> < ...

  2. SpringCloud微服务(04):Turbine组件,实现微服务集群监控

    本文源码:GitHub·点这里 || GitEE·点这里 写在前面,阅读本文前,你需要了解熔断器相关内容 SpringCloud微服务:Hystrix组件,实现服务熔断 一.聚合监控简介 1.Dash ...

  3. SpringCloud微服务学习笔记

    SpringCloud微服务学习笔记 项目地址: https://github.com/taoweidong/Micro-service-learning 单体架构(Monolithic架构) Mon ...

  4. springcloud微服务实战:Eureka+Zuul+Feign/Ribbon+Hystrix Turbine+SpringConfig+sleuth+zipkin

    相信现在已经有很多小伙伴已经或者准备使用springcloud微服务了,接下来为大家搭建一个微服务框架,后期可以自己进行扩展.会提供一个小案例: 服务提供者和服务消费者 ,消费者会调用提供者的服务,新 ...

  5. SpringCloud微服务简介(一)

    Spring Cloud简单认识 微服务英文名称Microservice,Microservice架构模式就是将整个Web应用组织为一系列小的Web服务.这些小的Web服务可以独立地编译及部署,并通过 ...

  6. springcloud微服务实战:Eureka+Zuul+Ribbon+Hystrix+SpringConfig

    原文地址:http://blog.csdn.net/yp090416/article/details/78017552 springcloud微服务实战:Eureka+Zuul+Ribbon+Hyst ...

  7. SpringCloud微服务:基于Nacos组件,整合Dubbo框架

    源码地址:GitHub·点这里 || GitEE·点这里 一.基础组件简介 1.Dubbo框架 Dubbo服务化治理的核心框架,之前几年在国内被广泛使用,后续由于微服务的架构的崛起,更多的公司转向微服 ...

  8. SpringCloud微服务项目实战 - API网关Gateway详解实现

    前面讲过zuul的网关实现,那为什么今天又要讲Spring Cloud Gateway呢?原因很简单.就是Spring Cloud已经放弃Netflix Zuul了.现在Spring Cloud中引用 ...

  9. 08 . Jenkins之SpringCloud微服务+Vue+Docker持续集成

    简介 大致流程 /* 1.开发人员每天把代码提交到Gitlab代码仓库 2.jenkins从gitlab中拉取项目源码,编译并打包成war包,然后构建Docker镜像,将镜像上传到Harbor私有仓库 ...

随机推荐

  1. JS高级 - 面向对象3(面向过程改写面向对象)

    改写: 1.前提:所有东西都在 onload 里 2.改写:不能有函数嵌套,可以有全局变量 onload --> 构造函数 全局变量 --> 属性 函数 --> 方法 4.改错: t ...

  2. 高版本js实现live

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. BZOJ1607 [Usaco2008 Dec]Patting Heads 轻拍牛头 筛法

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1607 题意概括 给出n个数,每一个数字<1000000,对于每一个数,让你求剩余的n-1个数 ...

  4. hihocode #1032 : 最长回文子串【manacher】模板题

    题目链接:https://vjudge.net/problem/HihoCoder-1032 manacher算法详解:https://blog.csdn.net/dyx404514/article/ ...

  5. 实现分布式服务注册及简易的netty聊天

    现在很多地方都会用到zookeeper, 用到它的地方就是为了实现分布式.用到的场景就是服务注册,比如一个集群服务器,需要知道哪些服务器在线,哪些服务器不在线. ZK有一个功能,就是创建临时节点,当机 ...

  6. 几个文本处理工具的简单使用(wc,cut,sort,uniq,diff和patch)

    wc wc命令用于报告文本文件的一些统计计数,例如行数.单词数.字节数等. 语法如下. wc [OPTION]... [FILE]... wc [OPTION]... --files0-from=F ...

  7. Linux/Window 正斜杠 反斜杠

    文件目录结构: Linux 是用正斜杠 目录名区分大小写 Window 是用反斜杠 目录名不区分大小写

  8. asp.net core for vs code

    1,命令 2,模板 3,更换启动浏览器 4,vscode使用nuget 5,使用ef migration 6,配置.net core的工作目录 7,使用dotnet ef migrations命令 8 ...

  9. NODESCHOOL

    来源:https://nodeschool.io/zh-cn/ 核心基础课程(Core) javascripting 学习 JavaScript 语言的基础,无需任何编程经验 npm install ...

  10. Bzoj2673 3961: [WF2011]Chips Challenge 费用流

    国际惯例题面:如果我们枚举放几个零件的话,第二个限制很容易解决,但是第一个怎么办?(好的,这么建图不可做)考虑我们枚举每行每列最多放几个零件t,然后计算零件总数sum.这样如果可行的话,则有t*B&l ...