Contents
  1. 1. 需求分析
  2. 2. Actuator 监控(不支持1.5.14.Release版本,支持1.5.9.Release)
    1. 2.1. 功能

单个应用程序:Actuator
所有的相关应用程序:Spring-boot-admin、Sleuth

需求分析

  1. Actuator提供单个微服务的所有文件配置、注册的Beans、MVC信息、相关服务器健康情况、JVM使用情况、线程情况、被访问的记录信息等
  2. Admin就是对多个微服务进行Actuator的图形化监控
  3. Sleuth监控所有注册的微服务的所有请求的耗时等相关信息,方便排查和服务器性能的优化。

Actuator 监控(不支持1.5.14.Release版本,支持1.5.9.Release)

http://www.cnblogs.com/ityouknow/p/8423590.html

功能

  1. 支持接口调用的方式关闭服务器
  2. 查看配置文件中设置的属性内容,以及一些配置属性的默认值。(MVC配置、数据源配置、Redis配置、Eureka配置等等全部)

    http://localhost:8088/monitor/configprops
    "spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties" : {
    "prefix" : "spring.redis",
    "properties" : {
    "port" : 6379,
    "host" : "127.0.0.1",
    "pool" : {
    "maxIdle" : 10,
    "minIdle" : 0,
    "maxActive" : 8,
    "maxWait" : 3000
    },
    "sentinel" : null,
    "cluster" : null,
    "ssl" : false,
    "password" : "******",
    "timeout" : 0,
    "url" : null,
    "database" : 0
    }
    },
  3. MVC相关的信息:

    http://localhost:8088/monitor/mappings
    "{[/code/getCodeGrid.do]}" : {
    "bean" : "requestMappingHandlerMapping",
    "method" : "public java.util.Map<java.lang.String, java.lang.Object> account_huang.action.CodeController.getCodeGrid(account_huang.utils.PageCoral,account_huang.utils.SearchEntity)"
    },
  4. Bean的相关信息:是否单例、依赖(引用)哪些类

    http://localhost:8088/monitor/beans
    {
    "bean" : "codeController",
    "aliases" : [ ],
    "scope" : "singleton",
    "type" : "account_huang.action.CodeController$$EnhancerBySpringCGLIB$$c824f51e",
    "resource" : "file [C:/huangzs/workspaceIdea/psm/target/classes/account_huang/action/CodeController.class]",
    "dependencies" : [ "codeService" ]
    }
    ```
    5. 依赖应用程序和相关引用的服务器的健康情况 /health(注册中心eureka、数据db、缓存数据库 redis、远程调用服务器PSM-User、磁盘是否充足、熔断器是否运行正常)等信息

http://localhost:8088/monitor/health

{
“description” : “Composite Discovery Client”,
“status” : “UP”,
“discoveryComposite” : {
“description” : “Composite Discovery Client”,
“status” : “UP”,
“discoveryClient” : {
“description” : “Composite Discovery Client”,
“status” : “UP”,
“services” : [ “spring-cloud-psm”, “spring-cloud-psm-user” ]
},
“eureka” : {
“description” : “Remote status from Eureka server”,
“status” : “UP”,
“applications” : {
“SPRING-CLOUD-PSM-USER” : 2,
“SPRING-CLOUD-PSM” : 1
}
}
},
“diskSpace” : {
“status” : “UP”,
“total” : 254320570368,
“free” : 97157308416,
“threshold” : 10485760
},
“redis” : {
“status” : “UP”,
“version” : “3.0.504”
},
“db” : {
“status” : “UP”,
“database” : “MySQL”,
“hello” : 1
},
“hystrix” : {
“status” : “UP”
}
}

- Server相关的信息
- JVM使用相关信息
- 网络请求相关的信息 trace
## 配置
只依赖Actuator.jar,配置参数即可使用。
注意事项,可以美化输出的json数据的格式。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

management:
security:
enabled: false #关掉安全认证
port: 8088 #管理端口调整成8088
context-path: /monitor #actuator的访问路径
endpoints:
shutdown:
enabled: true

spring:
jackson:
serialization:
indent_output: true

或者:
spring.jackson.serialization.indent_output= true
management.security.enabled= false
management.port= 8088
management.context-path= /monitor

# Spring Boot Admin监控
实现一个Admin管理界面,对多个SB项目进行图形化优化的监控功能,基于Actutaor接口
http://www.cnblogs.com/ityouknow/p/8440455.html
# Sleuth
http://www.ityouknow.com/springcloud/2018/02/02/spring-cloud-sleuth-zipkin.html
作用: 方便监控所有注册的微服务的所有请求的耗时等相关信息,方便排查和服务器性能的优化。
1. Sleuth是一个单独的服务器,其他程序通过注册sleuth,来实现注册式的监控。

spring.zipkin.base-url= http://localhost:9000
spring.sleuth.sampler.percentage= 1.0
```

  1. 主要是图形化和各种Filter的过滤器,和耗时的report,还有依赖关系图(比如zuul的转发依赖)

  2. 服务的访问url
    http://localhost:9000/zipkin/

  3. Sleuth依赖JDK 1.8以上

Contents
  1. 1. 需求分析
  2. 2. Actuator 监控(不支持1.5.14.Release版本,支持1.5.9.Release)
    1. 2.1. 功能