Add dashboard rule atlas
This commit is contained in:
parent
5db88d285e
commit
e43d7689a0
7 changed files with 130 additions and 17 deletions
|
|
@ -275,6 +275,27 @@ def posture_report(cfg: Config, runner=None) -> dict:
|
|||
}
|
||||
|
||||
|
||||
def rules_catalog(cfg: Config) -> dict:
|
||||
"""Return active event-rule metadata for the management console."""
|
||||
from . import ruleops
|
||||
|
||||
rules = ruleops.list_rules(cfg)
|
||||
by_event: dict[str, int] = {}
|
||||
by_severity: dict[str, int] = {}
|
||||
by_origin: dict[str, int] = {}
|
||||
for r in rules:
|
||||
by_event[r["event"]] = by_event.get(r["event"], 0) + 1
|
||||
by_severity[r["severity"]] = by_severity.get(r["severity"], 0) + 1
|
||||
by_origin[r["origin"]] = by_origin.get(r["origin"], 0) + 1
|
||||
return {
|
||||
"count": len(rules),
|
||||
"by_event": by_event,
|
||||
"by_severity": by_severity,
|
||||
"by_origin": by_origin,
|
||||
"rules": rules,
|
||||
}
|
||||
|
||||
|
||||
# --- HTTP layer ------------------------------------------------------------
|
||||
|
||||
class _Handler(BaseHTTPRequestHandler):
|
||||
|
|
@ -324,6 +345,8 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
self._json({"events": tail_events(cfg)})
|
||||
elif path == "/api/posture":
|
||||
self._json(posture_report(cfg))
|
||||
elif path == "/api/rules":
|
||||
self._json(rules_catalog(cfg))
|
||||
elif path == "/api/incidents":
|
||||
self._json(list_incidents(cfg))
|
||||
elif path.startswith("/api/incidents/"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue