【发布时间】:2017-01-29 15:37:49
【问题描述】:
Spring boot admin 是一个很棒的工具,可以让我的 Spring Boot 应用程序(在我的例子中是一个 Web 服务器)的运行状况和指标可用。我已经关注reference guide,终于可以让它运行了,不过有一个例外:服务器似乎无法识别客户端是否崩溃/宕机。
为了进行测试,我目前使用单独的应用程序,它们都在同一主机上运行。在最终版本中,我计划让多个客户端(运行在不同的 IP 地址上)向运行在其独立 IP 上的单个服务器注册)。
服务器(单独的 Spring Boot 项目)
pom.xml
...
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>
...
application.properties:
server.port=8081
我的主目录:
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class MyMain {
public static void main(String[] args) {
SpringApplication.run(MyMain.class, args);
}
}
客户端(我的 WebApp 被监控):
pom.xml:
...
<!-- SPRING BOOT ADMIN (CLIENT) -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
...
application.properties:
server.port=8080
spring.boot.admin.url=http://localhost:8081
spring.boot.admin.client.management-url=http://localhost:8081
spring.boot.admin.client.service-url=http://localhost:8080
spring.boot.admin.client.name=my-rest-app
通过此设置,我可以连接到 http://localhost:8080 以获取我的网络应用程序或连接到 http://localhost:8081 以查看管理/监控 UI。状态显示UP,我可以浏览mem/heap/traces/...
现在的问题是,如果我终止网络应用程序,状态仍然是 UP。
- 根据描述,我假设服务器属性
spring.boot.admin.monitor.period每 10 秒检查一次客户端应用程序的状态。 - 或者,我需要通知功能吗?
【问题讨论】:
-
您是否从 IDE 运行您的引导客户端?如果是,那么请尝试从终端运行 spring boot 客户端和管理员,我遇到了同样的问题。
标签: monitoring spring-boot-actuator