60
METRICS_SETUP.md
Normal file
60
METRICS_SETUP.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Metrics API Setup
|
||||
|
||||
## Configuración Base de Datos
|
||||
|
||||
PostgreSQL se ejecuta automáticamente en el contenedor Docker.
|
||||
|
||||
**Conexión:**
|
||||
- Host: localhost
|
||||
- Puerto: 5432
|
||||
- Base de datos: voxpopuli_metrics
|
||||
- Usuario: voxpopuli
|
||||
- Contraseña: voxpopuli_pass
|
||||
|
||||
**Tabla creada automáticamente:**
|
||||
```
|
||||
metrics:
|
||||
- id (PK)
|
||||
- event_type (STRING, INDEXED)
|
||||
- entity_id (STRING)
|
||||
- entity_type (STRING)
|
||||
- timestamp (DATETIME, INDEXED)
|
||||
- metadata (JSON)
|
||||
- user_id (INT, NULLABLE)
|
||||
```
|
||||
|
||||
## Arquitectura
|
||||
|
||||
```
|
||||
API Metrics (Puerto 8004)
|
||||
├── FastAPI Router
|
||||
│ ├── POST /metrics/record - Registrar métrica
|
||||
│ ├── GET /metrics/report - Reporte analítica
|
||||
│ ├── GET /metrics/daily-stats - Estadísticas diarias
|
||||
│ ├── GET /metrics/summary - Resumen eventos
|
||||
│ └── GET /metrics/health - Health check
|
||||
│
|
||||
├── Metrics Service (Lógica)
|
||||
│ └── Metrics Repository (Postgres)
|
||||
│
|
||||
└── Metrics Consumer (RabbitMQ)
|
||||
├── Escucha: users_queue
|
||||
├── Escucha: reports_queue
|
||||
├── Escucha: notifications_queue
|
||||
└── Escucha: moderations_queue
|
||||
```
|
||||
|
||||
## Inicio
|
||||
|
||||
```bash
|
||||
# Levantar DB (docker)
|
||||
docker-compose up -d
|
||||
|
||||
# Instalar dependencias
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Ejecutar todas las APIs
|
||||
python -m src.main
|
||||
```
|
||||
|
||||
La API de métricas se ejecutará automáticamente en puerto 8004.
|
||||
Reference in New Issue
Block a user