A production-focused microservices architecture built with NestJS to demonstrate distributed tracing, centralized logging, metrics collection, asynchronous messaging, and modern observability patterns.
This project demonstrates a production-style event-driven microservices architecture with full observability across distributed services.
The system models a simplified ecommerce checkout workflow where services communicate through synchronous HTTP requests and asynchronous RabbitMQ events while preserving distributed tracing context across network boundaries.
The primary focus of the project is observability engineering, including:
- Distributed tracing
- Metrics collection
- Structured logging
- Trace-to-log correlation
- Alerting pipelines
- Cross-service debugging
- OpenTelemetry instrumentation
| Service | Port | Responsibility |
|---|---|---|
| Order Gateway | 3000 |
Receives HTTP order requests |
| Payment Service | 3001 |
Simulates payment processing |
| Email Service | AMQP Consumer | Handles asynchronous email workflows |
Client Request
β
βΌ
Order Gateway
β HTTP
βΌ
Payment Service
β RabbitMQ Event
βΌ
Email Service
This project demonstrates three modern observability ecosystems.
| Stack | Components |
|---|---|
| Classic Stack | Prometheus + Grafana + Loki + Jaeger |
| ELK Stack | Elasticsearch + Logstash + Kibana + Filebeat |
| LGTM Stack | Loki + Grafana + Tempo + Mimir |
- OpenTelemetry instrumentation
- Jaeger trace visualization
- Tempo trace storage
- Manual trace context propagation
- Cross-service trace continuity
- Trace-to-log correlation
- Prometheus metrics collection
- Custom business metrics
- Request latency monitoring
- Grafana dashboards
- Alertmanager integration
- Metrics aggregation via Mimir
- Structured JSON logging with Pino
- Loki log aggregation
- ELK stack integration
- Trace ID injection into logs
- Multi-destination log shipping
- Cross-service log search
- RabbitMQ event publishing
- Async background processing
- Decoupled service communication
- Reliable message handling
- Distributed workflow tracing
| Layer | Technologies |
|---|---|
| Framework | NestJS (TypeScript) |
| Messaging | RabbitMQ |
| Tracing | OpenTelemetry, Jaeger, Tempo |
| Metrics | Prometheus, Grafana, Mimir |
| Logging | Loki, ELK Stack, Pino |
| Infrastructure | Docker, Docker Compose |
- Manual OpenTelemetry context propagation
- Distributed trace continuity across RabbitMQ
- Trace-enriched structured logging
- Multi-stack observability architecture
- Async event-driven service communication
- Dual log shipping (Loki + ELK)
- Centralized monitoring & alerting
The project demonstrates manual trace propagation across asynchronous message boundaries.
HTTP Request
β
βΌ
Order Gateway
β
Inject Trace Context
β
RabbitMQ Event
β
Extract Trace Context
βΌ
Email Service
This preserves distributed trace continuity even when transitioning from synchronous HTTP communication to asynchronous messaging.
- Node.js v18+
- Docker & Docker Compose
docker-compose -f observability/docker-compose.yml up -dThis starts:
- RabbitMQ
- Grafana
- Prometheus
- Loki
- Jaeger
npm installnpm run start order-gatewaynpm run start payment-servicenpm run start email-serviceGenerate observability data using:
curl -X POST http://localhost:3000/create-order| Tool | URL | Purpose |
|---|---|---|
| Grafana | http://localhost:4000 |
Metrics & logs |
| Grafana (LGTM) | http://localhost:5000 |
Unified LGTM dashboards |
| Kibana | http://localhost:5601 |
ELK log exploration |
| Jaeger | http://localhost:16686 |
Distributed trace visualization |
| Prometheus | http://localhost:9090 |
Raw metrics queries |
| Alertmanager | http://localhost:9093 |
Alert monitoring |
| RabbitMQ | http://localhost:15672 |
Queue monitoring |
| Elasticsearch | http://localhost:9200 |
Indexed log storage |
| Loki | http://localhost:3100 |
Log query API |
| Tempo | http://localhost:3200 |
Trace storage |
| Mimir | http://localhost:9009 |
Metrics storage |
Each service ships logs to both Loki and the ELK stack simultaneously.
NestJS Services
βββ Pino Logger
β
βββ Loki Pipeline
β βββ Grafana Explore
β
βββ File Logs
β
Filebeat
β
Logstash
β
Elasticsearch
β
Kibana
orders_created_totalhttp_request_duration_secondspayment_processed_total
- High error rate
- Service downtime
- Elevated request latency
- Queue processing failures
The LGTM stack enables deep observability correlation between:
- Logs
- Metrics
- Traces
- Open Grafana Explore
- Search logs in Loki
- Select a log line
- Jump directly to Tempo trace
- Navigate between spans and logs
This enables end-to-end debugging without manually copying trace IDs.
The ELK stack provides centralized indexing and advanced search capabilities for structured logs.
- Full-text log search
- Trace ID filtering
- Service-specific debugging
- Error monitoring
- Time-series log analysis
microservices-observability/
β
βββ apps/
β βββ order-gateway/
β βββ payment-service/
β βββ email-service/
β
βββ observability/
β βββ prometheus/
β βββ grafana/
β βββ loki/
β βββ jaeger/
β
βββ elk/
β βββ elasticsearch/
β βββ logstash/
β βββ filebeat/
β
βββ lgtm/
β βββ tempo/
β βββ mimir/
β βββ grafana/
β
βββ docker-compose.ymlThe Classic and LGTM stacks share several ports, including:
3100(Loki)4318(OTLP)
Run only one observability stack at a time.
- Kubernetes deployment support
- Distributed rate limiting
- Service mesh integration
- Kafka event streaming
- Auto-scaling observability stack
- CI/CD monitoring pipelines
Released under the MIT License.