Monitoring¶
Exposition API¶
L API expose:
GET /metrics(Prometheus via OpenTelemetry)GET /health/liveGET /health/ready
flowchart LR
API[API AdvancedDevSample] --> MET[/metrics/]
API --> LIVE[/health/live/]
API --> READY[/health/ready/]
Instrumentation¶
OpenTelemetry configure:
- traces: ASP.NET Core + HttpClient
- metriques: ASP.NET Core + HttpClient + exporter Prometheus
- export OTLP optionnel via
OTEL_EXPORTER_OTLP_ENDPOINTouOpenTelemetry:Otlp:Endpoint
flowchart LR
REQ[Requetes HTTP] --> OTel[Kit OpenTelemetry]
OTel --> TR[Traces]
OTel --> M[Metriques]
TR --> OTLP[Endpoint OTLP optionnel]
M --> PROM[/metrics pour Prometheus]
Stack locale¶
Fichiers:
docker-compose.ymlmonitoring/prometheus/prometheus.ymlmonitoring/prometheus/alert.rules.ymlmonitoring/grafana/provisioning/**monitoring/grafana/dashboards/api-observability.json
Lancement:
docker compose --profile monitoring up -d
Acces:
- Prometheus:
http://localhost:9090 - Grafana:
http://localhost:3000(admin/admin)
Alertes par defaut¶
AdvancedDevSampleHigh5xxRatioAdvancedDevSampleHighLatencyP95AdvancedDevSampleNoTraffic
flowchart TD
P[Collecte Prometheus] --> R[Regles d enregistrement et alertes]
R --> A1[High5xxRatio]
R --> A2[HighLatencyP95]
R --> A3[NoTraffic]
A1 --> N[Canal d alerte]
A2 --> N
A3 --> N
Verification rapide¶
- lancer la stack monitoring
- verifier
http://localhost:5069/metrics - verifier la cible API en
UPdans Prometheus - ouvrir le dashboard Grafana
AdvancedDevSample API Observability
flowchart LR
S[Demarrer le profil monitoring] --> M[Verifier /metrics]
M --> T[Cible API UP dans Prometheus]
T --> G[Ouvrir le dashboard Grafana]