docker.recipes

Zipkin Tracing

beginner

Distributed tracing system for latency analysis in microservices.

Overview

Zipkin is an open-source distributed tracing system originally developed by Twitter to help troubleshoot latency problems in microservice architectures. It collects timing data needed to troubleshoot latency issues, allowing developers to visualize request flows across multiple services and identify performance bottlenecks. Zipkin follows the OpenTracing standard and provides detailed insights into how requests propagate through distributed systems, making it essential for maintaining observable microservices. This configuration combines Zipkin with Elasticsearch as the storage backend, creating a powerful tracing platform that can handle high-volume trace data with advanced search and analytics capabilities. Elasticsearch provides Zipkin with scalable storage, fast querying, and the ability to perform complex aggregations on trace data, while the zipkin-dependencies service automatically generates service dependency graphs from collected traces. Development teams building microservices, DevOps engineers managing distributed systems, and organizations transitioning from monolithic to service-oriented architectures will find this stack invaluable for understanding system behavior and optimizing performance across service boundaries.

Key Features

  • B3 propagation support for seamless trace context propagation across HTTP requests
  • Real-time service dependency graph generation with automatic topology discovery
  • Latency percentile analysis with P50, P95, and P99 calculations for performance monitoring
  • Elasticsearch-powered full-text search across trace annotations and tags
  • Automatic trace retention and cleanup through Elasticsearch index lifecycle management
  • Support for multiple span types including client, server, producer, and consumer spans
  • Built-in sampling strategies to control trace collection overhead in high-traffic environments
  • RESTful API for programmatic trace submission and querying

Common Use Cases

  • 1Debugging performance bottlenecks in microservice architectures during development
  • 2Root cause analysis for intermittent latency spikes in production environments
  • 3Service dependency mapping for legacy system modernization projects
  • 4Performance regression testing in CI/CD pipelines with trace comparison
  • 5Capacity planning by analyzing request patterns and service utilization
  • 6SLA monitoring and alerting based on service-level latency metrics
  • 7API gateway performance optimization through upstream service analysis

Prerequisites

  • Minimum 2GB RAM for Elasticsearch storage backend (4GB recommended for production)
  • Port 9411 available for Zipkin web UI and API access
  • Basic understanding of distributed tracing concepts and span terminology
  • Application instrumentation with Zipkin-compatible tracing libraries
  • Docker Engine 19.03+ with Docker Compose v2 support
  • At least 10GB free disk space for trace data storage and Elasticsearch indices

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 zipkin:
3 image: openzipkin/zipkin:latest
4 container_name: zipkin
5 environment:
6 - STORAGE_TYPE=elasticsearch
7 - ES_HOSTS=elasticsearch:9200
8 ports:
9 - "9411:9411"
10 depends_on:
11 - elasticsearch
12 networks:
13 - zipkin-network
14 restart: unless-stopped
15
16 elasticsearch:
17 image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
18 container_name: zipkin-elasticsearch
19 environment:
20 - discovery.type=single-node
21 - xpack.security.enabled=false
22 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
23 volumes:
24 - elasticsearch-data:/usr/share/elasticsearch/data
25 networks:
26 - zipkin-network
27 restart: unless-stopped
28
29 zipkin-dependencies:
30 image: openzipkin/zipkin-dependencies:latest
31 container_name: zipkin-dependencies
32 environment:
33 - STORAGE_TYPE=elasticsearch
34 - ES_HOSTS=elasticsearch:9200
35 depends_on:
36 - elasticsearch
37 networks:
38 - zipkin-network
39 entrypoint: crond -f
40
41volumes:
42 elasticsearch-data:
43
44networks:
45 zipkin-network:
46 driver: bridge

.env Template

.env
1# Zipkin
2# Send traces to http://localhost:9411/api/v2/spans

Usage Notes

  1. 1Zipkin UI at http://localhost:9411
  2. 2Send traces via HTTP POST
  3. 3Service dependency graph
  4. 4Latency percentile analysis
  5. 5Supports B3 propagation

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

zipkin
zipkin:
  image: openzipkin/zipkin:latest
  container_name: zipkin
  environment:
    - STORAGE_TYPE=elasticsearch
    - ES_HOSTS=elasticsearch:9200
  ports:
    - "9411:9411"
  depends_on:
    - elasticsearch
  networks:
    - zipkin-network
  restart: unless-stopped
elasticsearch
elasticsearch:
  image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
  container_name: zipkin-elasticsearch
  environment:
    - discovery.type=single-node
    - xpack.security.enabled=false
    - ES_JAVA_OPTS=-Xms512m -Xmx512m
  volumes:
    - elasticsearch-data:/usr/share/elasticsearch/data
  networks:
    - zipkin-network
  restart: unless-stopped
zipkin-dependencies
zipkin-dependencies:
  image: openzipkin/zipkin-dependencies:latest
  container_name: zipkin-dependencies
  environment:
    - STORAGE_TYPE=elasticsearch
    - ES_HOSTS=elasticsearch:9200
  depends_on:
    - elasticsearch
  networks:
    - zipkin-network
  entrypoint: crond -f

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 zipkin:
5 image: openzipkin/zipkin:latest
6 container_name: zipkin
7 environment:
8 - STORAGE_TYPE=elasticsearch
9 - ES_HOSTS=elasticsearch:9200
10 ports:
11 - "9411:9411"
12 depends_on:
13 - elasticsearch
14 networks:
15 - zipkin-network
16 restart: unless-stopped
17
18 elasticsearch:
19 image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
20 container_name: zipkin-elasticsearch
21 environment:
22 - discovery.type=single-node
23 - xpack.security.enabled=false
24 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
25 volumes:
26 - elasticsearch-data:/usr/share/elasticsearch/data
27 networks:
28 - zipkin-network
29 restart: unless-stopped
30
31 zipkin-dependencies:
32 image: openzipkin/zipkin-dependencies:latest
33 container_name: zipkin-dependencies
34 environment:
35 - STORAGE_TYPE=elasticsearch
36 - ES_HOSTS=elasticsearch:9200
37 depends_on:
38 - elasticsearch
39 networks:
40 - zipkin-network
41 entrypoint: crond -f
42
43volumes:
44 elasticsearch-data:
45
46networks:
47 zipkin-network:
48 driver: bridge
49EOF
50
51# 2. Create the .env file
52cat > .env << 'EOF'
53# Zipkin
54# Send traces to http://localhost:9411/api/v2/spans
55EOF
56
57# 3. Start the services
58docker compose up -d
59
60# 4. View logs
61docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/zipkin-tracing/run | bash

Troubleshooting

  • Zipkin UI shows no traces: Verify applications are instrumented and sending traces to http://localhost:9411/api/v2/spans
  • Elasticsearch connection refused errors: Wait for Elasticsearch to fully start (30-60 seconds) before Zipkin attempts connection
  • Out of memory errors in Elasticsearch: Increase ES_JAVA_OPTS heap size from 512m to 1g or higher based on trace volume
  • zipkin-dependencies service not generating dependency graphs: Check that spans have proper service names and that Elasticsearch contains trace data
  • High CPU usage on zipkin-dependencies: Adjust cron schedule in entrypoint or limit dependency analysis to specific time ranges
  • Traces not appearing in UI after submission: Check Elasticsearch cluster health and verify STORAGE_TYPE environment variable is set correctly

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space