- 建立项目加入maven依赖,这是一个web项目,所以也加入spring boot web依赖,一般情况会与注册中心配合使用,需要的可以加入注册中心客户端依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.12.0</version>
</dependency>
- 日志监控启动类
@SpringBootApplication
@EnableEurekaClient
@EnableZipkinServer
public class ZipkinApplication {
public static void main(String[] args) {
SpringApplication.run(ZipkinApplication.class, args);
}
}
3.application.yml
server:
port: 9411
spring:
application:
name: zipkin-server
profiles:
active: dev
management:
metrics:
web:
server:
auto-time-requests: false
eureka:
client:
service-url:
defaultZone: http://root:zxy2019@192.168.2.90:8001/eureka/
instance:
hostname: ${spring.cloud.client.ip-address}
instance-id: ${eureka.instance.hostname}:${server.port}
prefer-ip-address: true
客户端服务调用
6. 添加maven依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
- zipkin配置文件
spring:
sleuth:
sampler:
probability: 1.0 #日志采集频率,最高1.0全部收集,可以为小数2位0.01,就是1%
#开放监控端点
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS