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.
gateway(UI + API): gọiordersvàinventoryorders: tạo đơn hàng giả lập, có random failureinventory: trừ tồn kho giả lập, có random failureotel-collector: nhận telemetry OTLP từ servicesprometheus: scrape metrics từ collectorloki: lưu logstempo: lưu tracesgrafana: giao diện quan sát tập trung + dashboard mẫu
Yêu cầu: Docker Desktop đang chạy.
docker compose up --build -dMở các URL:
- App demo: http://localhost:8000
- Grafana: http://localhost:3000 (user/pass:
admin/admin) - Prometheus: http://localhost:9090
- Mở http://localhost:8000
- Bấm
Bắn tải 3 req/sđể tạo traffic liên tục - Sau 10-30 giây, mở Grafana để quan sát
- Vào Dashboards → Demo →
Microservice Observability Overview - Có sẵn biểu đồ:
- Throughput checkout
- p95 latency checkout
- Orders created rate
- Inventory reserve failures
- Vào Explore
- Chọn datasource: Loki
- Query nhanh:
hoặc lọc theo service:
{}{service_name="gateway"}
- 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
docker compose downdocker compose down -v