84 lines
1.4 KiB
Python
84 lines
1.4 KiB
Python
"""
|
|
©AngelaMos | 2026
|
|
logs.py
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
from flask import Blueprint
|
|
|
|
from app.controllers import log_ctrl
|
|
from app.core.decorators import endpoint, S, R
|
|
from app.schemas.log_event import (
|
|
LogIngestRequest,
|
|
LogQueryParams,
|
|
LogSearchParams,
|
|
PivotParams,
|
|
)
|
|
|
|
|
|
logs_bp = Blueprint("logs", __name__)
|
|
|
|
|
|
@logs_bp.get("")
|
|
@endpoint()
|
|
@S(LogQueryParams, source = "query")
|
|
@R()
|
|
def list_logs() -> Any:
|
|
"""
|
|
Return paginated and filtered log events
|
|
"""
|
|
return log_ctrl.list_logs()
|
|
|
|
|
|
@logs_bp.get("/<log_id>")
|
|
@endpoint()
|
|
@R()
|
|
def get_log(log_id: str) -> Any:
|
|
"""
|
|
Return a single log event by ID
|
|
"""
|
|
return log_ctrl.get_log(log_id)
|
|
|
|
|
|
@logs_bp.post("/ingest")
|
|
@endpoint(auth_required = False)
|
|
@S(LogIngestRequest)
|
|
@R(status = 201)
|
|
def ingest_log() -> Any:
|
|
"""
|
|
Ingest a raw log event into the pipeline
|
|
"""
|
|
return log_ctrl.ingest_log()
|
|
|
|
|
|
@logs_bp.get("/search")
|
|
@endpoint()
|
|
@S(LogSearchParams, source = "query")
|
|
@R()
|
|
def search_logs() -> Any:
|
|
"""
|
|
Full text search across log events
|
|
"""
|
|
return log_ctrl.search_logs()
|
|
|
|
|
|
@logs_bp.get("/stream")
|
|
@endpoint()
|
|
def stream_logs() -> Any:
|
|
"""
|
|
SSE stream of real-time log events
|
|
"""
|
|
return log_ctrl.stream_logs()
|
|
|
|
|
|
@logs_bp.get("/pivot")
|
|
@endpoint()
|
|
@S(PivotParams, source = "query")
|
|
@R()
|
|
def pivot() -> Any:
|
|
"""
|
|
Forensic pivot by IP, username, or hostname
|
|
"""
|
|
return log_ctrl.pivot()
|