seluth 和 zipkin利用起来,可以很简单的做到微服务的监控,
注意使用的版本,有些小坑,版本不对,服务都注册不上
- spring cloud 使用的Greenwich.SR1
- spring boot 使用的 2.1.3.RELEASE
- zipkin 使用的 2.9.3 【因为 cloud 版本里面使用的是这个版本,保持一致】
1.1 建立zipkin项目,增加对应的依赖
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.9.3</version>
</dependency>
1.2 增加配置文件的配置
因为报错,所以增加下面的配置
【spring cloud】spring cloud集成zipkin报错:Prometheus requires that all meters with the same name have the same set of tag keys.
server:
port: 8811
spring:
application:
name: demo-springcloud-zipkin
main:
allow-bean-definition-overriding: true
management:
metrics:
web:
server:
auto-time-requests: false
1.3 增加主代码配置
@EnableZipkinServer
@SpringBootApplication
public class DemoSpringcloudZipkinApplication {
public static void main(String[] args) {
SpringApplication.run(DemoSpringcloudZipkinApplication.class, args);
}
}
1.4 打开页面,预览
http://127.0.0.1;8811

1.5 被监控方接入,增加依赖
两个项目都需要增加
- demo-springcloud-order
- demo-springcloud-gateway
<!--链路跟踪器-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
1.6 开始利用gateway进行访问order的接口

1.7 查看链路调用图



网友评论