PatrickRedStar's picture
fix
946b940
# schemas/schemas.py
# Схемы для валидации выходных данных агентов анализа логов
parser_schema = {
"type": "object",
"properties": {
"events": {
"type": "array",
"items": {
"type": "object",
"properties": {
"line_number": {"type": "integer"},
"timestamp": {"type": ["string", "null"]},
"level": {"type": "string"},
"message": {"type": "string"},
"type": {"type": "string"}
},
"required": ["line_number", "level", "message"]
}
},
"errors": {
"type": "array",
"items": {"type": ["object", "string"]}
},
"warnings": {
"type": "array",
"items": {"type": ["object", "string"]}
},
"statistics": {
"type": "object",
"properties": {
"total_lines": {"type": "integer"},
"parsed_events": {"type": "integer"},
"errors": {"type": "integer"},
"warnings": {"type": "integer"},
"info_messages": {"type": "integer"},
"event_types": {"type": "object"},
"time_range": {
"type": ["object", "null"],
"properties": {
"start": {"type": ["string", "null"]},
"end": {"type": ["string", "null"]}
}
}
},
"required": ["total_lines", "parsed_events", "errors", "warnings"]
}
},
"required": ["events", "errors", "warnings", "statistics"]
}
anomaly_schema = {
"type": "object",
"properties": {
"anomalies": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {"type": "string"},
"severity": {"type": "string"},
"description": {"type": "string"},
"count": {"type": ["integer", "null"]},
"error_message": {"type": ["string", "null"]},
"metadata": {"type": ["object", "null"]}
},
"required": ["type", "severity", "description"]
}
},
"statistics": {
"type": "object",
"properties": {
"total": {"type": "integer"},
"by_type": {"type": "object"},
"by_severity": {"type": "object"}
}
},
"severity_summary": {"type": "object"}
},
"required": ["anomalies", "statistics", "severity_summary"]
}
rca_schema = {
"type": "object",
"properties": {
"analysis": {
"type": "object",
"properties": {
"root_causes": {
"type": "array",
"items": {"type": "string"}
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"anomaly_type": {"type": "string"},
"severity": {"type": "string"},
"description": {"type": "string"},
"possible_causes": {
"type": "array",
"items": {"type": "string"}
}
}
}
}
}
},
"recommendations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"priority": {"type": "string"},
"text": {"type": "string"},
"actions": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["priority", "text"]
}
},
"general_recommendations": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["analysis", "recommendations", "general_recommendations"]
}