spring boot admin系統監控處理

沉澱發表於2017-08-15

1.系統監控使用springboot admin

2.springboot admin server

2.1 修改pom.xml增加dependency

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

2.2 啟動類SpringbootApplication增加admin註解支援

@SpringBootApplication
@EnableAutoConfiguration
@EnableAdminServer
public class SpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }

}

2.3 修改屬性檔案application.properties

server.display-name=springbootserver
server.context-path=/
server.servlet-path=/
server.port=8090
# admin
spring.boot.admin.url=http://localhost:${server.port}

3.springboot admin client

3.1 修改pom.xml增加dependency

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>1.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.jolokia</groupId>
            <artifactId>jolokia-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

3.2 修改屬性檔案application.properties

server.display-name=springbootserver
server.context-path=/
server.servlet-path=/
server.port=8090
# admin
spring.boot.admin.url=http://localhost:8090

3.3 logback.xml增加配置

<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <jmxConfigurator/>
</configuration>

啟動server和client即可檢視應用的狀態

http://localhost:8090

相關文章