started log ingestion and analysis

This commit is contained in:
Jake Kasper
2026-04-24 14:15:58 -04:00
parent c2537dd955
commit 9ac96cee9a
27 changed files with 1368 additions and 179 deletions

View File

@@ -8,6 +8,8 @@ import re
from app.config import ALL_NFS
from app.services import pls, prometheus
_last_inventory: dict | None = None
ROLE_NF_MAP = {
"5GALL": {"amf", "smf", "pcf", "udr", "udm", "nrf", "eir", "ausf", "dra", "upf", "chf", "smsf", "aaa", "bmsc"},
"CP": {"amf", "smf", "pcf", "udr", "udm", "nrf", "eir", "ausf", "dra", "chf", "smsf", "aaa", "bmsc"},
@@ -41,9 +43,10 @@ def _infer_role(hostname: str) -> str:
async def get_cluster_inventory() -> dict:
global _last_inventory
cluster = await pls.get_cluster_status()
if not cluster:
return {
return _last_inventory or {
"enabled": False,
"current_node": None,
"fully_established": False,
@@ -78,12 +81,14 @@ async def get_cluster_inventory() -> dict:
}
)
return {
inventory = {
"enabled": True,
"current_node": cluster.get("current_node"),
"fully_established": bool(cluster.get("fully_established")),
"nodes": nodes,
}
_last_inventory = inventory
return inventory
def _aggregate_nf_state(nf_name: str, nodes: list[dict], prom_states: dict[str, dict]) -> dict:
@@ -137,8 +142,14 @@ def _attach_node_nf_status(nodes: list[dict]) -> list[dict]:
enriched = []
for node in nodes:
node_copy = dict(node)
expected_nfs = node_copy.get("expected_nfs", [])
node_copy["nfs"] = [_node_nf_state(node_copy, nf_name.upper()) for nf_name in expected_nfs]
expected_nfs = {nf.upper() for nf in node_copy.get("expected_nfs", [])}
started_nf_services = {
svc.get("name", "").upper()
for svc in node_copy.get("services", [])
if svc.get("type") == "nf" and svc.get("name")
}
visible_nfs = sorted(expected_nfs | started_nf_services)
node_copy["nfs"] = [_node_nf_state(node_copy, nf_name.upper()) for nf_name in visible_nfs]
enriched.append(node_copy)
return enriched