赞
踩
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
在浏览器中输入如下的网址
http://localhost:8080/actuator/info
http://localhost:8080/actuator/health
SpringBoot 中提供了非常多的默认端点监控,但是出于安全考虑,默认情况下有些端点并不是开启状态,如 shutdown 端点就是默认关闭的。
SpringBoot 在运行时就会自动开发/actuator/health和/actuator/info这两个endpoint
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always # 可以看到具体哪个是down,其中一个为down,那么status就是down
http方法 | Endpoint | 描述 |
---|---|---|
GET | /actuator | 查看有哪些 Actuator endpoint 是开放的 |
GET | /actuator/auditevent | 查看 audit 的事件,例如认证进入、订单失败,需要搭配 Spring Security |
GET | /actuator/beans | 查看全部的 bean,以及它们的关系 |
GET | /actuator/conditions | 查看自动配置的结果,记录哪些自动配置条件通过了,哪些没通过 |
GET | /actuator/configprops | 查看带有 @ConfigurationProperties 的 properties 值为何(包含默认值) |
GET | /actuator/env | 查看全部环境属性 |
GET | /actuator/flyway | 查看 flyway DB 的 migration 资讯 |
GET | /actuator/health | 查看当前 SpringBoot 运行的健康指标 |
GET | /actuator/heapdump | 取得 JVM 当下的 heap dump,会下载一个档案 |
GET | /actuator/info | 查看 properties 中 info开头的属性的值,沒啥用 |
GET | /actuator/mappings | 查看全部的 endpoint,以及他们和 Controller 的关系 |
GET | /actuator/metrics | 查看有哪些指标可以看 |
GET | /actuator/scheduledtasks | 查看定時任务的资讯 |
POST | /actuator/shutdown | 唯一一個需要 POST 请求的 endpoint,关闭这个 SpringBoot 程序 |
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.3.1</version>
</dependency>
@SpringBootApplication
@EnableAdminServer
public class Demo2Application {
public static void main(String[] args) {
SpringApplication.run(Demo2Application.class, args);
}
}
在之前的redisdemo工程中添加以下依赖
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.3.1</version>
</dependency>
在之前的redisdemo工程中配置admin-server的地址
spring:
boot:
admin:
client:
url: http://localhost:8080
instance:
service-url: http://localhost:${server.port}
启动redisdemo工程
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。