美文网首页
【十一】Spring Cloud seluth

【十一】Spring Cloud seluth

作者: lemonMT | 来源:发表于2019-03-15 18:50 被阅读0次

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


image.png

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的接口

image.png

1.7 查看链路调用图

image.png image.png image.png

相关文章

网友评论

      本文标题:【十一】Spring Cloud seluth

      本文链接:https://www.haomeiwen.com/subject/pxodpqtx.html