Skip to content

Commit 9103933

Browse files
committed
feat: add comprehensive observability stack with metrics, logging, and monitoring
## Major Features Added: - 🔍 Prometheus metrics collection for all API endpoints - 📊 Grafana dashboards with weather service monitoring - 📝 Structured logging with correlation IDs and JSON format - 🚨 AlertManager with pre-configured alert rules - 📈 Loki log aggregation and analysis - 🏥 Health check endpoints (/health, /health/ready, /health/live) - 🐳 Complete Docker Compose observability stack ## New Components: - weather_mcp/observability.py - Core observability infrastructure - weather_mcp/health.py - Health check endpoints - monitoring/ - Complete monitoring configuration - docker-compose.observability.yml - Full stack deployment - scripts/start-observability.sh - Easy startup script - OBSERVABILITY.md - Comprehensive documentation ## Enhanced Services: - Added @track_api_request decorators to all service methods - Structured logging with correlation IDs - Prometheus metrics for API performance, cache hit rates, SSE connections - Error tracking and external API monitoring ## New Make Commands: - make start-observability - Start full monitoring stack - make docker-dev-run - Renamed from run-docker-dev - make observability-up/down/logs/restart - make health-check, metrics-check, observability-status ## Access Points: - Weather MCP: http://localhost:8000 - Grafana: http://localhost:3000 (admin/admin) - Prometheus: http://localhost:9091 - AlertManager: http://localhost:9093 This provides production-ready observability for the Weather MCP server.
1 parent b652f89 commit 9103933

File tree

22 files changed

+2527
-23
lines changed

22 files changed

+2527
-23
lines changed

Makefile

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help install install-dev test test-unit test-integration coverage lint format format-check type-check clean dev-setup pre-commit run run-test docker-build docker-run run-docker-dev docker-logs docker-stop
1+
.PHONY: help install install-dev test test-unit test-integration coverage lint format format-check type-check clean dev-setup pre-commit run run-test docker-build docker-run docker-dev-run docker-logs docker-stop
22

33
# Default target
44
help:
@@ -19,7 +19,7 @@ help:
1919
@echo " run Run weather API server"
2020
@echo " docker-build Build Docker image"
2121
@echo " docker-run Start Docker container with docker-compose"
22-
@echo " run-docker-dev Start Docker container in development mode"
22+
@echo " docker-dev-run Start Docker container in development mode"
2323
@echo " docker-logs View Docker container logs"
2424
@echo " docker-stop Stop Docker containers"
2525

@@ -91,11 +91,54 @@ docker-build:
9191
docker-run:
9292
docker-compose up -d clima-mcp
9393

94-
run-docker-dev:
94+
docker-dev-run:
9595
docker-compose --profile dev up clima-mcp-dev
9696

9797
docker-logs:
9898
docker-compose logs -f clima-mcp
9999

100100
docker-stop:
101101
docker-compose down
102+
103+
# =============================================================================
104+
# OBSERVABILITY
105+
# =============================================================================
106+
107+
start-observability:
108+
@echo "🔍 Starting full observability stack..."
109+
./scripts/start-observability.sh
110+
111+
observability-up:
112+
docker-compose -f docker-compose.observability.yml up -d
113+
114+
observability-down:
115+
docker-compose -f docker-compose.observability.yml down
116+
117+
observability-logs:
118+
docker-compose -f docker-compose.observability.yml logs -f
119+
120+
observability-restart:
121+
docker-compose -f docker-compose.observability.yml restart
122+
123+
grafana-open:
124+
@echo "Opening Grafana dashboard..."
125+
@open http://localhost:3000 || echo "Visit http://localhost:3000 (admin/admin)"
126+
127+
prometheus-open:
128+
@echo "Opening Prometheus..."
129+
@open http://localhost:9091 || echo "Visit http://localhost:9091"
130+
131+
health-check:
132+
@echo "🏥 Checking service health..."
133+
@curl -s http://localhost:8000/health | jq . || echo "Service not responding"
134+
135+
metrics-check:
136+
@echo "📊 Checking metrics..."
137+
@curl -s http://localhost:8000/metrics | head -20
138+
139+
observability-status:
140+
@echo "📊 Observability Stack Status:"
141+
@echo "Weather MCP: $$(curl -s -o /dev/null -w "%%{http_code}" http://localhost:8000/health || echo "DOWN")"
142+
@echo "Prometheus: $$(curl -s -o /dev/null -w "%%{http_code}" http://localhost:9091/-/healthy || echo "DOWN")"
143+
@echo "Grafana: $$(curl -s -o /dev/null -w "%%{http_code}" http://localhost:3000/api/health || echo "DOWN")"
144+
@echo "Loki: $$(curl -s -o /dev/null -w "%%{http_code}" http://localhost:3100/ready || echo "DOWN")"

0 commit comments

Comments
 (0)