Use springboot admin in spring cloud

  springboot, springcloud

maven

        <!--spring boot admin-->
        <!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server</artifactId>
            <version>1.4.6</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--&lt;!&ndash; https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui-turbine &ndash;&gt;-->
        <!--<dependency>-->
            <!--<groupId>de.codecentric</groupId>-->
            <!--<artifactId>spring-boot-admin-server-ui-activiti</artifactId>-->
            <!--<version>1.4.6</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui-turbine</artifactId>
            <version>1.4.6</version>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui</artifactId>
            <version>1.4.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>

Here, because the spring boot versions are inconsistent, eclude start web in admin server.
Spring-boot-admin-server-ui-activiti didn’t see any use, so it was commented out.
Spring-boot-admin-server-ui-turbine was used because turbine was used to aggregate hystrix.

Configuration

spring.boot.admin:
#  routes:
#    endpoints: env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,hystrix.stream,turbine.stream,activiti
  turbine:
    clusters: default
    url: http://localhost:8889/turbine.stream

Access
http://localhost:8889/#/turbine
图片描述

Dynamically modify log levels

Logback is required and jmxConfigurator is opened.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <!--<logger name="com.codecraft.graphite" level="DEBUG"/>-->

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are  by default assigned the type
             ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %level [%thread] %caller{1} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="info">
        <appender-ref ref="STDOUT" />
    </root>

    <jmxConfigurator/>
</configuration>

You also need to rely on jolokia to expose jmx operations in the form of http.

<dependency>
   <groupId>org.jolokia</groupId>
   <artifactId>jolokia-core</artifactId>
</dependency>

Then you can dynamically modify the log level
图片描述

doc