A complete observability stack for Kubernetes demonstrating monitoring, logging, and tracing using industry-standard tools.
- Metrics Collection: Prometheus with custom service metrics
- Log Aggregation: Loki with structured logging (Winston)
- Visualization: Grafana dashboards
- API Gateway: Kong for service routing
- Auto-rotation: Log rotation and size management
- Resource Monitoring: Node and container-level metrics
# Docker Desktop with Kubernetes
# - Minimum 4GB memory allocated
# - Kubernetes enabled in settings
# - Version 4.x or higher
# Tilt
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
# Helm 3
brew install helm # macOS
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add kong https://charts.konghq.com
helm repo update
# kubectl
brew install kubectl # macOS
- Prometheus: Metrics collection and storage
- Service metrics via prom-client
- Node metrics via node-exporter
- Kubernetes state metrics
- Grafana: Visualization (http://localhost:3002)
- Services Dashboard
- Operations Dashboard
- Kong Dashboard
- Logs Dashboard
- Loki: Log aggregation and querying
- Promtail: Log collection with rotation
- Max file size: 10Mi
- Retention: 24h
- Winston: Structured logging in services
- Kong: Service routing and API management
- Admin API: http://localhost:8001
- Proxy: http://localhost:8000
- Service A: Example Node.js service with:
- Custom metrics
- Structured logging
- Trace instrumentation
- Service B: Similar setup for comparison
-
Prepare Environment
# Clone repository git clone https://github.com/yourusername/k8s-observability-stack.git cd k8s-observability-stack # Start Docker Desktop # Enable Kubernetes in settings
-
Deploy Stack
# Start all services tilt up
-
Verify Installation
# Check pods kubectl get pods -n observability # Check services kubectl get svc -n observability
Service | URL | Credentials |
---|---|---|
Grafana | http://localhost:3002 | admin/admin |
Prometheus | http://localhost:9090 | N/A |
Loki | http://localhost:3100 | N/A |
Service A | http://localhost:3000 | N/A |
Service B | http://localhost:3001 | N/A |
Kong Admin | http://localhost:8001 | N/A |
├── charts/
│ ├── monitoring/ # Helm values for monitoring stack
│ │ ├── grafana-values.yaml
│ │ ├── loki-values.yaml
│ │ └── prometheus-values.yaml
│ ├── services/ # Microservices Helm charts
│ └── kong/ # API Gateway configuration
├── services/
│ ├── service-a/ # Example service with Winston logging
│ └── service-b/ # Example service
└── Tiltfile # Tilt configuration
- Create service directory in
services/
- Add Helm chart in
charts/services/
- Update
Tiltfile
- Add metrics to Grafana dashboard
- Update values in
charts/monitoring/
- Update service configuration in
charts/services/
- Run
tilt up
to apply changes
-
Memory Pressure
# Check resource usage kubectl top pods -n observability
-
Log Collection Issues
# Check Promtail logs kubectl logs -l app=promtail -n observability
-
Service Discovery
# Verify service endpoints kubectl get endpoints -n observability
- Persistence not enabled by default
- Single-node deployment optimized for development
- Limited to local Kubernetes cluster
- Fork the repository
- Create feature branch
- Submit Pull Request
MIT License - See LICENSE file for details