Skip to content

Docker With Zipkin#

What Is The ZipKin?#

  • Zipkin is an open-source distributed tracing system used to monitor and troubleshoot microservices-based distributed systems It helps gather timing data needed to troubleshoot latency problems in service architectures. Features include both the collection and lookup of this data.
  • With Zipkin, developers can identify the root cause of performance issues, latency, and errors in distributed systems, which is essential for maintaining the health and reliability of these systems.
  • More Information

Create Zipkin Server With Docker Compose#

  • Let's create a file name docker-compose.yml, then add scripts as below:
docker-compose.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# This runs the zipkin and zipkin-mysql containers, using docker-compose's
# default networking to wire the containers together.
#
# Note that this file is meant for learning Zipkin, not production deployments.

version: '3.7'

services:
  storage:
    image: openzipkin/zipkin-mysql
    container_name: storage
    command: --default-authentication-plugin=mysql_native_password
    environment:
      - MYSQL_ROOT_PASSWORD=zipkin
      - MYSQL_DATABASE=zipkin
      - MYSQL_USER=zipkin
      - MYSQL_PASSWORD=zipkin
    # Uncomment to expose the storage port for testing
    # ports:
    #   - 3306:3306
    volumes:
    - ./mysql-data:/var/lib/mysql:rw

  # The zipkin process services the UI, and also exposes a POST endpoint that
  # instrumentation can send trace data to. Scribe is disabled by default.
  zipkin:
    image: openzipkin/zipkin
    container_name: zipkin
    # Environment settings are defined here https://github.com/openzipkin/zipkin/blob/master/zipkin-server/README.md#environment-variables
    environment:
      - STORAGE_TYPE=mysql
      # Point the zipkin at the storage backend
      - MYSQL_HOST=storage
      - MYSQL_USER=zipkin
      - MYSQL_PASS=zipkin
      - MYSQL_DB=zipkin
      # Uncomment to enable scribe
      # - SCRIBE_ENABLED=true
      # Uncomment to enable self-tracing
      # - SELF_TRACING_ENABLED=true
      # Uncomment to enable debug logging
      # - JAVA_OPTS=-Dlogging.level.zipkin2=DEBUG
    ports:
      # Port used for the Zipkin UI and HTTP Api
      - 9411:9411
      # Uncomment if you set SCRIBE_ENABLED=true
      # - 9410:9410
    depends_on:
      - storage

  # Adds a cron to process spans since midnight every hour, and all spans each day
  # This data is served by http://192.168.99.100:8080/dependency
  #
  # For more details, see https://github.com/openzipkin/docker-zipkin-dependencies
  dependencies:
    image: openzipkin/zipkin-dependencies
    container_name: dependencies
    entrypoint: crond -f
    environment:
      - STORAGE_TYPE=mysql
      - MYSQL_HOST=storage
      # Add the baked-in username and password for the zipkin-mysql image
      - MYSQL_USER=zipkin
      - MYSQL_PASS=zipkin
      # Uncomment to see dependency processing logs
      # - ZIPKIN_LOG_LEVEL=DEBUG
      # Uncomment to adjust memory used by the dependencies job
      # - JAVA_OPTS=-verbose:gc -Xms1G -Xmx1G
    depends_on:
      - storage

volumes:
  mysql-data:
  • In this docker-compose.yml we will create 3 services, in which the MySQL database storage service is used for storing tracing information that the service Zipkin has received from Reporter services.
  • Next, the dependencies service is a component of the distributed tracing system called Zipkin. It is used to analyze and visualize the dependencies between services in a distributed system.
  • When multiple services are involved in processing a single request, the dependencies service can help identify which services depend on each other and how often they communicate. It analyzes the data collected by Zipkin tracing components to generate a dependency graph that shows how services are related to each other.
  • The dependencies service is typically used in conjunction with other Zipkin components, such as zipkin-server and zipkin-collector, to provide a complete distributed tracing system for monitoring and troubleshooting microservices-based applications.
  • Finally, the zipkin service is used to run the Zipkin server, which is the central component of the tracing system. It provides a web interface for querying and visualizing the tracing data, and also stores the data in a backend storage such as Elasticsearch or MySQL. The Docker image includes the Zipkin server and the default storage backend (in-memory) for testing purposes, as well as the UI and collector modules. The Zipkin UI is accessible via a web browser, allowing users to visualize and analyze the tracing data.

Testing#

  • Now you can use command docker-compose up to start your Zipkin server. Then access the URL http://localhost:9411 then you will be the Zipkin UI as below.

 #zoom

References#