42 lines
1.1 KiB
Markdown
42 lines
1.1 KiB
Markdown
# Metrics API Examples
|
|
|
|
## Registrar métrica manualmente
|
|
```bash
|
|
curl -X POST "http://localhost:8004/metrics/record" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"event_type": "user_created",
|
|
"entity_id": "123",
|
|
"entity_type": "user",
|
|
"user_id": 456,
|
|
"metadata": {"email": "user@example.com"}
|
|
}'
|
|
```
|
|
|
|
## Obtener reporte de últimos 7 días
|
|
```bash
|
|
curl "http://localhost:8004/metrics/report?days=7"
|
|
```
|
|
|
|
## Obtener estadísticas de un día específico
|
|
```bash
|
|
curl "http://localhost:8004/metrics/daily-stats?date=2026-05-04T00:00:00"
|
|
```
|
|
|
|
## Obtener resumen de eventos en rango
|
|
```bash
|
|
curl "http://localhost:8004/metrics/summary?start_date=2026-04-27T00:00:00&end_date=2026-05-04T23:59:59"
|
|
```
|
|
|
|
## Health check
|
|
```bash
|
|
curl "http://localhost:8004/metrics/health"
|
|
```
|
|
|
|
## Eventos automáticos (RabbitMQ)
|
|
El consumer de métricas escucha automáticamente eventos de:
|
|
- Users Queue: `user_created`, `user_updated`, `user_deleted`
|
|
- Reports Queue: `report_created`, `report_resolved`
|
|
- Notifications Queue: `notification_sent`
|
|
- Moderations Queue: `moderation_completed`
|