Spring Boot Admin Page

前端 未结 2 2063
暖寄归人
暖寄归人 2021-02-10 23:28

I am trying to understand how to use SBAP in my application because it is a very handy tool for development. I\'m reading their reference guide but I\'m not understanding a few

相关标签:
2条回答
  • 2021-02-10 23:48

    I don't think the recommendation is NOT to use Spring boot admin in production for monitoring, ofcourse, after you ensure that there is some level of security that is built in.

    The correct usage pattern for SBAP is to think about it as a standalone application that provides an aggregated view of all of your Springboot services via a GUI. Infact, as long as HEALTH/METRICS urls are exposed via ACTUATOR, the MONITORED services do not even need to be aware of the fact there is some application that is monitoring it's status.

    SBAP can PULL all METRICS from standard endpoints after it discovers your services from a Service Registry like EUREKA as that totally decouples SBAP from being statically aware of any service other than EUREKA itself. A sample YAML configuration and JAVA code is as follows

    @SpringBootApplication
    @EnableDiscoveryClient
    @EnableAdminServer
    public class SpringbootAdminApplication {
    
       public static void main(String[] args) {
          SpringApplication.run(SpringbootAdminApplication.class, args);
       }
    }
    

    bootstrap.yml

      eureka:
        instance:
           leaseRenewalIntervalInSeconds: 10
        client:
          registerWithEureka: false
          fetchRegistry: true
          serviceUrl:
            defaultZone: http://localhost:8761/eureka/
      spring:
        boot:
         admin:
           url: http://localhost:8080
        cloud:
          config:
            enabled: false
    

    With the 2 configurations above alone in a SpringBoot project,it would become a SBAP server that can be accessed via "http://localhost:8080" and monitor your services.

    0 讨论(0)
  • 2021-02-11 00:03
    1. So am I registering my application as the server and the client?

    In your example, you do. It's not problem that the admin server is a client to itself. In fact the spring-boot-admin-sample is configured this way so you get infos about the admin server itself.

    1. How do I run this application and access the admin page? They don't mention any URL to go to to see the admin page. Is it just: http://localhost:8080?

    Yes. If you don't set the spring.boot.admin.context-path the admin is served on root. So if you ship the admin along inside your business-app you should configure spring.boot.admin.context-path so that it's served elsewhere.

    1. How do I set this up for development but turn it off in production? There reference guide at the bottom says: ...

    The point is just to use two separate applications. This is the way we do it from dev-, over qa- to production-stage. We always separate the business- from the admin-server. If you want to enable the admin-server inside your business-application conditionally try this approach: Write an @Configuration-class wich is only active within a certain profile and move the @EnableAdminServer to this configuration.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题