Your SpaceWatch application has been successfully enhanced with AWS S3 and Azure Blob Storage style metrics and logging - focused exclusively on storage operations.
IMPORTANT: SpaceWatch now supports multi-tenant usage! Each request must provide its own DigitalOcean Spaces credentials.
Required Headers for All Requests:
X-Spaces-Key: Your DigitalOcean Spaces access keyX-Spaces-Secret: Your DigitalOcean Spaces secret key
Optional Headers:
X-Log-Bucket: Your bucket for access logsX-Metrics-Bucket: Your bucket for metricsX-Log-Prefix: Prefix for access logs (default: "")X-Metrics-Prefix: Prefix for metrics (default: "spacewatch-metrics/")
Authentication:
- User endpoints (chat, tools, metrics for user buckets) - No API key required, uses Spaces credentials
- Admin endpoints (/admin/api/*, /metrics/operations, /logs/operations, /stats) - Requires
X-API-Keyheader
See README.md for detailed multi-tenant usage examples.
A new dashboard panel displays live storage metrics (auto-refreshes every 30 seconds):
- Operations/sec - Current request rate to your storage
- Total Operations - Count of operations in last 5 minutes
- Error Rate - Percentage of failed operations
- Data Transfer/sec - Bandwidth utilization
- Latency P50/P95/P99 - Performance percentiles
- Operation Breakdown - Detailed breakdown by operation type
Health Status Indicator:
- π’ Healthy - Error rate < 5%
- π‘ Degraded - Error rate 5-10%
- π΄ Unhealthy - Error rate > 10%
Get detailed storage operation analytics:
curl -H "X-API-Key: your_key" http://localhost:8000/metrics/operationsReturns:
- Current 5-minute metrics
- 1-hour and 24-hour trends
- Per-bucket analytics
- Operation type breakdown
Query storage operation logs (S3-style):
# Get all operations
curl -H "X-API-Key: your_key" http://localhost:8000/logs/operations
# Filter by operation type
curl -H "X-API-Key: your_key" http://localhost:8000/logs/operations?operation_type=LIST_OBJECTS
# Find slow operations (>1 second)
curl -H "X-API-Key: your_key" http://localhost:8000/logs/operations?min_duration_ms=1000
# Filter by bucket
curl -H "X-API-Key: your_key" http://localhost:8000/logs/operations?bucket=my-bucketNow includes comprehensive storage metrics:
curl http://localhost:8000/healthEvery storage operation is logged with detailed metrics:
Normal Operations:
2024-01-15 10:30:45 [INFO] STORAGE_OP: LIST_OBJECTS | GET /tools/list-all | status=200 | duration=45.23ms | bytes=2048 | bucket=my-bucket
Slow Operations (>5 seconds):
2024-01-15 10:35:12 [WARNING] SLOW_OPERATION: QUERY_LOGS - 5234.56ms - bucket=logs-bucket status=200
Failed Operations:
2024-01-15 10:40:30 [ERROR] STORAGE_OP_ERROR: LIST_OBJECTS | GET /tools/list-all | duration=156.78ms | error=Bucket not found
Every API response includes monitoring headers:
X-Request-Duration-Ms: 45.23
X-Request-Id: req-1705318245123
X-Operation-Type: LIST_OBJECTSUse these for debugging and request tracing across your systems.
First Time Setup:
Before starting the application, run the interactive setup wizard:
# Install dependencies
pip install -r requirements.txt
# Run interactive setup
python setup.pyThe setup wizard will guide you through configuring:
- AI Agent URL and API Key (required)
- Application API Key for security (optional)
- Default DigitalOcean Spaces region (optional)
Already Configured?
If you already have a .env file, you can skip the setup and go directly to starting the application.
# Start the server
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadOpen your browser to:
http://localhost:8000
You'll see the new Storage Operations Health panel at the top of the dashboard showing real-time metrics!
The dashboard will automatically:
- Track all storage operations
- Calculate latency percentiles
- Monitor error rates
- Display operation breakdown
- Auto-refresh every 30 seconds
Use the new API endpoints to integrate with your monitoring systems:
# Get current storage metrics
curl http://localhost:8000/health | jq '.storage_metrics'
# Get detailed operation analytics
curl http://localhost:8000/metrics/operations | jq .
# View recent operation logs
curl http://localhost:8000/logs/operations?limit=10 | jq .- LIST_BUCKETS - Bucket discovery operations
- LIST_OBJECTS - Object listing in buckets
- ANALYZE_STORAGE - Storage analysis (top largest, summaries)
- QUERY_METRICS - Metrics retrieval
- QUERY_LOGS - Log queries
- AI_QUERY - AI assistant queries
- Latency Percentiles (P50, P95, P99)
- Average Latency
- Operations per Second
- Bytes per Second
- Error Rate (%)
- Success Rate (%)
- Failed Operation Count
- Operation count
- Error rate
- Bytes transferred
- Average latency
Your SpaceWatch now has similar metrics to:
β
Request metrics (AllRequests, GetRequests, PutRequests)
β
Error metrics (4xxErrors, 5xxErrors)
β
Latency metrics (FirstByteLatency, TotalRequestLatency)
β
Data transfer metrics (BytesDownloaded, BytesUploaded)
β
Transaction metrics
β
Success/Error rates
β
Latency percentiles
β
Availability indicators
β
Egress metrics
Default: 10,000 operations
# In main.py
MAX_STORAGE_METRICS_SAMPLES = 20000 # Increase to 20kDefault: 5 seconds
# In main.py, record_storage_operation function
if duration_ms > 3000: # Change to 3 seconds
logger.warning(...)Default: 5 minutes
# In get_storage_metrics function
recent_window = 600 # Change to 10 minutesFull documentation is available in these files:
- METRICS_GUIDE.md - Comprehensive guide to all metrics features
- IMPROVEMENTS_SUMMARY.md - Detailed technical summary
- README.md - Updated quick start guide
# Check if latency is acceptable
curl http://localhost:8000/health | jq '.storage_metrics | {p50, p95, p99}'# Monitor error rate
curl http://localhost:8000/health | jq '.storage_metrics.error_rate_percent'# Track operation trends
curl http://localhost:8000/metrics/operations | jq '.trends'# Find slow operations
curl http://localhost:8000/logs/operations?min_duration_ms=1000 | jq .All existing features continue to work:
- β AI chat assistant
- β Bucket and object management
- β Access log analysis
- β Metrics snapshots
- β Storage analytics
- β IP tracking
The new features are additive only - everything you had before still works!
- Start the application and check out the new dashboard
- Monitor your storage operations in real-time
- Integrate with external monitoring using the new API endpoints
- Set up alerts based on error rates or latency thresholds
- Analyze operation patterns to optimize your storage usage
For questions or issues:
- Check METRICS_GUIDE.md for detailed documentation
- Review IMPROVEMENTS_SUMMARY.md for technical details
- Check the application logs for any errors
Enjoy your enhanced storage observability! π
Your SpaceWatch application now provides enterprise-grade storage monitoring similar to AWS S3 CloudWatch and Azure Blob Storage Analytics!