先来看需要哪些包,下面是我的pom依赖的包,这个功能只要前两个依赖就行
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-turbine</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-activiti</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
下面是我的配置,增加endpoints接口:hystrix.stream和turbine.stream,turbine.location所属应用(就是用admin本身),其中turbine.app-config需要配置监控的服务名称
spring:
application:
name: boot-admin
boot:
admin:
routes:
endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,turbine.stream,activiti
turbine:
location: boot-admin
username: "${security.user.name}"
password: "${security.user.password}"
client:
metadata:
user.name: "${security.user.name}"
user.password: "${security.user.password}"
server:
port: 8484
eureka:
instance:
instanceId: ${spring.application.name}:${server.port}
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
healthcheck:
enabled: true
custom.print: hello
turbine:
cluster-name-expression: new String("default")
app-config: book-service,api-gateway
combine-host-port: true
management:
security:
enabled: false
security:
user:
name: user
password: pass
开启turbine注解
@EnableTurbine
启动服务,分别能全局查看所有服务接口情况,和分别进入各服务里查看,关于怎么读懂这张图,请参考netflix公司的github:https://github.com/Netflix/Hystrix