Dev Logging and Monitoring Setup Guide ====================================== Create a logging and monitoring setup guide for [application]. Application details: - Application: [name] - Language: [language] - Cloud: [AWS/GCP/Azure] - Current logging: [none/console only/structured] - Monitoring tool: [DataDog/New Relic/Prometheus/CloudWatch] LOGGING AND MONITORING GUIDE 1. LOGGING BEST PRACTICES LOG LEVELS - ERROR: [application errors requiring immediate attention] - WARN: [unexpected situations that are not errors] - INFO: [significant business events] - DEBUG: [diagnostic information — disabled in production] WHAT TO LOG ✓ Application start/stop ✓ All errors with stack traces ✓ External API calls (request/response/duration) ✓ Database query duration (slow queries) ✓ Authentication events (login/logout/failed) ✓ Business events (order placed/payment processed) ✓ Background job start/completion/failure WHAT NOT TO LOG ✗ Passwords or secrets ✗ Full credit card numbers ✗ PII without masking ✗ Raw SQL with parameters (mask values) 2. STRUCTURED LOGGING FORMAT ```json { "timestamp": "2024-01-15T10:30:00Z", "level": "INFO", "service": "order-service", "traceId": "abc123", "userId": "user_456", "event": "order.created", "orderId": "ord_789", "amount": 99.99, "duration_ms": 145 } ``` 3. METRICS TO TRACK GOLDEN SIGNALS - Latency: [p50/p95/p99 response times] - Traffic: [requests per second] - Errors: [error rate %] - Saturation: [CPU/memory/queue depth] BUSINESS METRICS - [Orders per minute] - [Active users] - [Conversion rate] - [Revenue per hour] 4. ALERTING RULES | Alert | Condition | Severity | Action | | High error rate | >1% for 5min | P1 | Page on-call | | High latency | p99 >2s for 5min | P2 | Notify team | | Memory high | >85% for 10min | P2 | Notify | | Disk space | >80% | P3 | Ticket | 5. DISTRIBUTED TRACING - Correlation ID: [generate at entry point] - Propagate: [through all service calls] - Log with every request: [trace ID in all logs] - Tool: [Jaeger/Zipkin/AWS X-Ray] 6. DASHBOARD SETUP - Overview dashboard: [key service health] - Error dashboard: [error breakdown] - Performance dashboard: [latency/throughput] - Business dashboard: [key business metrics] - On-call dashboard: [what responder needs first] Source: https://promptzyo.com/prompt/dev-logging-and-monitoring-setup-guide