SpringBoot——Actuator监控使用
Actuator监控使用步骤
1.导入坐标依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2.访问http://localhost:8080/actuator
http://localhost:8080/actuator
{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"health-path": {
"href": "http://localhost:8080/actuator/health/{*path}",
"templated": true
},
"health": { //健康检查,非详细信息
"href": "http://localhost:8080/actuator/health",
"templated": false
},
"info": { //配置文件中以info开头的属性信息
"href": "http://localhost:8080/actuator/info",
"templated": false
}
}
}
①http://localhost:8080/actuator/info
配置文件中以info开头的属性信息(application.properties)
info.author=aikin
info.date=2020.12.08
{
"author": "aikin",
"date": "2020.12.08"
}
②http://localhost:8080/actuator/health
健康检查(可以检查引入的第三方的组件,如redis的状态)
#开启健康检查的完整信息
management.endpoint.health.show-details=always
③暴露所有监控的endpoints(默认只有health和info)
#将所有监控的endpoints暴露出来
management.endpoints.web.exposure.include=*
Spring Boot Admin监控(图形化界面)
●Spring Boot Admin 是一个开源社区项目,用于管理和监控SpringBoot应用程序。(图形化界面)
●Spring Boot Admin 有两个角色,客户端(client)和服务端(server)。
1.admin-server
①创建admin-server模块
②导入依赖坐标admin-starter-server
③在引导类上启动监控功能@EnableAdminServer
server.port=9090
2.admin-client
①创建admin-client模块
②导入依赖坐标admin-starter-client
③配置相关信息,server地址等
#指定admin.server的地址
spring.boot.admin.client.url=http://localhost:9090
④启动server和client服务,访问server
http://localhost:9090/
2960

被折叠的 条评论
为什么被折叠?



