Skip to content

Repository files navigation

Microservice Observability Demo (OpenTelemetry)

Demo này tạo một hệ thống microservice đơn giản để quan sát:

  • Metrics (Prometheus + Grafana)
  • Logs (Loki + Grafana)
  • Tracing (Tempo + Grafana)
  • Dùng OpenTelemetry để instrument từ ứng dụng và chuyển qua OpenTelemetry Collector.

Kiến trúc

  • gateway (UI + API): gọi ordersinventory
  • orders: tạo đơn hàng giả lập, có random failure
  • inventory: trừ tồn kho giả lập, có random failure
  • otel-collector: nhận telemetry OTLP từ services
  • prometheus: scrape metrics từ collector
  • loki: lưu logs
  • tempo: lưu traces
  • grafana: giao diện quan sát tập trung + dashboard mẫu

Chạy nhanh

Yêu cầu: Docker Desktop đang chạy.

docker compose up --build -d

Mở các URL:

Cách tạo traffic

  1. Mở http://localhost:8000
  2. Bấm Bắn tải 3 req/s để tạo traffic liên tục
  3. Sau 10-30 giây, mở Grafana để quan sát

Xem metrics, logs, tracing trên Grafana

1) Metrics (graph)

  • Vào DashboardsDemoMicroservice Observability Overview
  • Có sẵn biểu đồ:
    • Throughput checkout
    • p95 latency checkout
    • Orders created rate
    • Inventory reserve failures

2) Logs

  • Vào Explore
  • Chọn datasource: Loki
  • Query nhanh:
    {}
    
    hoặc lọc theo service:
    {service_name="gateway"}
    

3) Traces

  • Vào Explore
  • Chọn datasource: Tempo
  • Chạy query TraceQL cơ bản:
    { name = "checkout_flow" }
    
  • Mở trace để thấy span đi qua gateway -> orders -> inventory

Dừng hệ thống

docker compose down

Dọn dữ liệu và stop

docker compose down -v

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages