目录
监控的意义:
监控服务状态是否宕机
监控服务运行指标(内存、虚拟机、线程、请求等)
监控日志
管理服务(服务下线)
监控的实施方式:
1 要有一个服务器,这个服务器要把被监控的服务信息展示出来
2 在运行的服务中做设置,主动上报给服务器我被监控了,我的哪些东西被你监控了.

Spring boot admin:
开源社区项目,用于管理和监控SpringBoot应用程序.
客户端注册到服务端后,通过http请求方式,服务端定期从客户端获取对应的信息,并通过UI界面展示信息.
创建一个新模块--ops 选code..server
1 pom文件server坐标那里添加和parent 一样的版本号
2 开启web


- <dependency>
- <groupId>de.codecentric</groupId>
- <artifactId>spring-boot-admin-starter-server</artifactId>
- <version>2.7.1</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
3 引导类加注解@EnableAdminServer

此时打开浏览器 http://localhost:8080/ 就能看到监控画面了
创建一个新模块--ops 选code..client
1 pom文件client坐标那里添加和parent 一样的版本号
2 开启web

- <dependency>
- <groupId>de.codecentric</groupId>
- <artifactId>spring-boot-admin-starter-client</artifactId>
- <version>2.7.1</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
3 配置文件
- #设置端口,client的端口不要和server的端口冲突
- server:
- port: 81
- spring:
- boot:
- admin:
- client:
- # 此url指向server端
- url: http://localhost:8080
-
- management:
- # 开启了health 信息
- endpoint:
- health:
- show-details: always
- # 开启了全部信息
- endpoints:
- web:
- exposure:
- # *别忘加引号
- include: "*"
启动client的程序

浏览器刷新就会出现被监控的client服务

备注:如果不好用请检查jdk版本,我最开始用的jdk18的版本client启动之后,就没有被监控到,换成jdk8就好了
看一下监控的信息
应用


应用墙

点应用墙这里也能进去看被监控的服务具体信息
细节

性能
环境
类
配置属性
日志配置
线程存储
复制client和web的坐标,添加配置信息,修改端口
有web操作可以监控uri


