This document outlines how to monitor, log, and alert for the FakeStoreNet application.
- Request Latency: track response time for critical endpoints (
/products,/users,/carts). - Error Rates: count 4xx and 5xx responses, categorize by endpoint.
- Database Performance: monitor query duration and connection pool usage.
Use Prometheus to scrape metrics exposed by ASP.NET Core (e.g., via prometheus-net).
- Structured logging using Serilog:
- Enrich logs with
RequestId,UserId, andCorrelationId. - Output to console (development) and to a centralized sink (e.g., Elasticsearch).
- Enrich logs with
- Log levels:
- Error: unhandled exceptions, failed operations.
- Warning: business rule violations (e.g., adding zero quantity).
- Information: high-level events (e.g., user registration, cart creation).
- Distributed tracing with OpenTelemetry:
- Instrument HTTP pipeline, Entity Framework Core queries, and custom domain operations.
- Export traces to Jaeger or Zipkin for request flow analysis.
- Configure alerts in Prometheus Alertmanager:
- High error rate (>5% HTTP 5xx).
- Elevated request latency (p95 > 500ms).
- Database connection errors.
- Send alerts via email or Slack channel.
- Grafana dashboard panels for:
- API throughput and latency.
- Error breakdown by service.
- Database health and resource usage.