feat: add router health metrics to node_cache and node-guardian
- Add migration 042_node_cache_router_metrics.sql - Node guardian now collects router health and sends in heartbeat - City-service uses cached router_healthy from node_cache - This allows NODE2 router status to be displayed correctly
This commit is contained in:
@@ -255,6 +255,20 @@ class NodeGuardian:
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Swapper metrics collection failed: {e}")
|
||||
|
||||
# Collect Router Metrics using node-specific URL
|
||||
metrics["router_healthy"] = False
|
||||
metrics["router_version"] = None
|
||||
try:
|
||||
r = await self.client.get(f"{self.router_url}/health", timeout=3.0)
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
status = data.get("status", "").lower()
|
||||
metrics["router_healthy"] = status in ("healthy", "ok")
|
||||
metrics["router_version"] = data.get("version")
|
||||
logger.debug(f"🔀 Router metrics: healthy={metrics['router_healthy']}, version={metrics['router_version']}")
|
||||
except Exception as e:
|
||||
logger.debug(f"Router health check failed: {e}")
|
||||
|
||||
return metrics
|
||||
|
||||
|
||||
Reference in New Issue
Block a user