Spring Boot Admin无法解析URL以确保健康和管理

时间:2018-09-12 13:21:22

标签: spring-boot-admin

  • 春季版本:5.0.8.RELEASE
  • Spring Boot依赖项版本:2.0.4.RELEASE
  • Java版本:1.8.0_131

Spring Boot Admin报告客户端已关闭。但是,通过在浏览器中导航到客户端,我可以看到该客户端正在运行。在Sprint Boot Admin中客户端的详细信息视图上,运行状况部分下的消息为“获取运行状况失败,网络错误”。详细信息页面标题中显示了三个URL:

http://localhost:8090/WorkOrderPrinting
http://localhost:8090/WorkOrderPrinting/manage
http://localhost:8090/WorkOrderPrinting/manage/health

单击它们将打开相应的视图。这是运行状况视图的输出:

{"status":"UP","details":{"diskSpace":{"status":"UP","details":{"total":80482930688,"free":77726302208,"threshold":10485760}},"db":{"status":"UP","details":{"tenantRoutingDataSource":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}},"userSetTenantRoutingDS":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}},"dataSourceCbCommon":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}},"dataSourceCbOrg":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}}}}}}

似乎告诉我客户端应用程序已启动并正在运行。所以我不确定为什么Sprint Boot Admin UI无法反映这一点。

我有第二个应用程序作为客户端运行,并且按预期方式工作。运行状况URL的结果相同。

{"status":"UP","details":{"diskSpace":{"status":"UP","details":{"total":80482930688,"free":77726248960,"threshold":10485760}},"db":{"status":"UP","details":{"tenantRoutingDataSource":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}},"userSetTenantRoutingDS":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}},"dataSourceCbCommon":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}},"dataSourceCbOrg":{"status":"UP","details":{"database":"Informix Dynamic Server","hello":104}}}}}}

Spring Boot Admin Server日志显示“工作单打印”错误。再次,不确定为什么URL有效,但是日志显示错误。

2018-09-13 09:19:19.071 DEBUG 5208 --- [     parallel-2] d.c.b.a.server.services.StatusUpdater    : Update status for Instance(id=6212ad7c5ab4, version=1, registration=Registration(name=Work Order Printing Development, managementUrl=http://localhost:8090/WorkOrderPrinting/manage, healthUrl=http://localhost:8090/WorkOrderPrinting/manage/health, serviceUrl=http://localhost:8090/WorkOrderPrinting, source=http-api), registered=true, statusInfo=StatusInfo(status=DOWN, details={error=Found, status=302}), statusTimestamp=2018-09-13T13:15:08.169Z, info=Info(values={}), endpoints=Endpoints(endpoints={health=Endpoint(id=health, url=http://localhost:8090/WorkOrderPrinting/manage/health)}), buildVersion=null)

Spring Boot Admin服务器配置

server.servlet.context-path=/adminserver
logging.file=/var/log/eti/webui/adminserver.log
logging.level.de.codecentric.boot.admin.server=INFO

客户端配置失败

    #Admin Panel config
    #
    #This is the URL for the admin panel that this application will send its information to
    spring.boot.admin.client.url=http://localhost:8080/adminserver
    #This is required when deploying to Tomcat because the Admin panel cant seem to determine what the URL will be on its own 
    spring.boot.admin.client.instance.service-base-url=http://localhost:8090
    #This is the name that will be displayed in the admin panel for this application
    spring.boot.admin.client.instance.name=Work Order Printing
    # 
    spring.boot.admin.auto-registration=true
    #
    #Actuator config needed to expose endpoints to admin panel
    #
    management.endpoints.web.base-path=/manage
    management.endpoints.web.exposure.include:*
    management.endpoint.health.show-details=always

工作客户端配置

    #Admin Panel config
    #
    #This is the URL for the admin panel that this application will send its information to
    spring.boot.admin.client.url=http://localhost:8080/adminserver
    #This is required when deploying to Tomcat because the Admin panel cant seem to determine what the URL will be on its own 
    spring.boot.admin.client.instance.service-base-url=http://localhost:8085
    #This is the name that will be displayed in the admin panel for this application
    spring.boot.admin.client.instance.name=LaunchPad
    spring.boot.admin.auto-registration=true
    #
    #Actuator config needed to expose endpoints to admin panel
    #
    management.endpoints.web.base-path=/manage
    management.endpoints.web.exposure.include:*
    management.endpoint.health.show-details=always

1 个答案:

答案 0 :(得分:0)

因此,该问题实际上是我的配置问题。 Admin Server日志显示以下内容:

2018-09-13 09:19:19.071 DEBUG 5208 --- [     parallel-2] d.c.b.a.server.services.StatusUpdater    : Update status for Instance(id=6212ad7c5ab4, version=1, registration=Registration(name=Work Order Printing Development, managementUrl=http://localhost:8090/WorkOrderPrinting/manage, healthUrl=http://localhost:8090/WorkOrderPrinting/manage/health, serviceUrl=http://localhost:8090/WorkOrderPrinting, source=http-api), registered=true, statusInfo=StatusInfo(status=DOWN, details={error=Found, status=302}), statusTimestamp=2018-09-13T13:15:08.169Z, info=Info(values={}), endpoints=Endpoints(endpoints={health=Endpoint(id=health, url=http://localhost:8090/WorkOrderPrinting/manage/health)}), buildVersion=null)

基本上是说发生了302(重定向)事件,因此无法到达URL。我忘记允许在Spring Security配置中访问URL的原因。我可以通过浏览器访问他们,因为我已经登录。SpringBoot Admin无法登录,因为它尚未登录。

我添加了一条规则,以允许访问/ manage /网址

 public void configure(WebSecurity web) throws Exception
{
    web.ignoring().antMatchers("/css/**", "/fonts/**", "/img/**", "/js/**", "/close", "/webjars/**", "/manage/**");
}