feat: Add alert endpoints to alert_processor service for dashboard

Implemented missing alert endpoints that the dashboard requires for
health status and action queue functionality.

Alert Processor Service Changes:
- Created alerts_repository.py:
  * get_alerts() - Filter alerts by severity/status/resolved with pagination
  * get_alerts_summary() - Count alerts by severity and status
  * get_alert_by_id() - Get specific alert

- Created alerts.py API endpoints:
  * GET /api/v1/tenants/{tenant_id}/alerts/summary - Alert counts
  * GET /api/v1/tenants/{tenant_id}/alerts - Filtered alert list
  * GET /api/v1/tenants/{tenant_id}/alerts/{alert_id} - Single alert

- Severity mapping: "critical" (dashboard) maps to "urgent" (alert_processor)
- Status enum: active, resolved, acknowledged, ignored
- Severity enum: low, medium, high, urgent

API Server Changes:
- Registered alerts_router in api_server.py
- Exported alerts_router in __init__.py

Procurement Client Changes:
- Updated get_critical_alerts() to use /alerts path
- Updated get_alerts_summary() to use /alerts/summary path
- Added severity mapping (critical → urgent)
- Added documentation about gateway routing

This fixes the 404 errors for alert endpoints in the dashboard.
This commit is contained in:
Claude
2025-11-07 22:16:16 +00:00
parent 6cd4ef0f56
commit 41d292913a
5 changed files with 413 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ from fastapi.middleware.cors import CORSMiddleware
import structlog
from app.config import AlertProcessorConfig
from app.api import analytics_router
from app.api import analytics_router, alerts_router
from shared.database.base import create_database_manager
logger = structlog.get_logger()
@@ -31,6 +31,7 @@ app.add_middleware(
# Include routers
app.include_router(analytics_router, tags=["analytics"])
app.include_router(alerts_router, tags=["alerts"])
# Initialize database
config = AlertProcessorConfig()