分布式链路监控Zipkin + EKL + RabbitMQ

使用 springboot2.x  

Zipkin服务端

pom配置



    4.0.0

    com.zipkin
    zipkin
    1.0-SNAPSHOT
    jar

    

        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
            2.0.1.RELEASE
        

        
            com.google.code.gson
            gson
            2.8.5
        
        
        
            io.zipkin.java
            zipkin-server
            2.11.1
        
        
            io.zipkin.java
            zipkin-autoconfigure-ui
            2.11.1
        

        
            io.zipkin.java
            zipkin-autoconfigure-storage-elasticsearch-http
            2.8.4
        

        
            io.zipkin.java
            zipkin-autoconfigure-collector-rabbitmq
            2.11.1
        
        
            org.springframework.boot
            spring-boot-starter-security
            2.0.4.RELEASE
            
                
                    org.springframework.boot
                    spring-boot-starter
                
            
        

    

    
        
            
                src/main/java
                
                    **/*.xml
                
                true
            
            
                src/main/resources
                
                    **
                
                true
            
        
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    1.8
                    1.8
                
            

            
                org.springframework.boot
                spring-boot-maven-plugin
                2.0.4.RELEASE
                
                    
                        
                            repackage
                        
                    
                
            
        
    


application.yml配置文件信息

spring:
  sleuth:
    enabled: false
  application:
    name: zipkin-server
  security:  #密码认证
    basic:
      enabled: true
    user:
      name: sleuth-zipkin
      password: 123456
  profiles:
    active: local

server:
  port: 10000

register:
  port: 10000

#访问服务注册中心管理页面需要加密码
register-visite-name: eureka
register-visite-passwd: 123456


management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
  metrics:
    web:
      server:
        auto-time-requests: false

active 本地信息 application-local.yml

zipkin:
  storage:
    elasticsearch:
      cluster: elasticsearch-zipkin-cluster
      max-requests: 64
      index-replicas: 1
      hosts: 192.168.19.7:9200
      index: zipkin
      index-shards: 5
    StorageComponent: elasticsearch
    type: elasticsearch
  collector:
    rabbitmq:
      addresses: 192.168.19.7:5672
      password: guest
      username: guest
      queue: zipkin
eureka:
  instance:
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ipaddress}:${server.port}
  client:
    service-url:
      defaultZone: http://${register-visite-name}:${register-visite-passwd}@localhost:${register.port}/eureka/
    registry-fetch-interval-seconds: 3  #获取服务的刷新时间

启动文件 ZipkinApplication.java

package com.zipkin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import zipkin2.server.internal.EnableZipkinServer;


@SpringBootApplication
@EnableDiscoveryClient
@EnableZipkinServer
public class ZipkinApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZipkinApplication.class,args);
    }
}

认证文件  

@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // For example: Use only Http Basic and not form login.
        http.authorizeRequests()
            .anyRequest().authenticated()
            .and()
            .httpBasic();
    }
}

服务端配置 

pom 添加依赖项 .因为其他项目还是使用 springboot1.x版本 ,因此zipkin版本用的 1.3.3.RELEASE  ,rabbit 用的1.73.RELEASE


   org.springframework.cloud
   spring-cloud-starter-zipkin



   org.springframework.amqp
   spring-rabbit

客户端配置文件 加入rabbitmq配置 及 zipkin接收的rabbitmq 队列

spring:
  rabbitmq:
    addresses: 192.168.19.7
    port: 5672
    username: guest
    password: guest
zipkin:
  rabbitmq:
    queue: zipkin

 

 

git 项目下载地址  https://github.com/yanzuoyu/zipkin.git

 

你可能感兴趣的:(分布式链路监控Zipkin + EKL + RabbitMQ)