Visla Guardian - AI SRE Agent π‘οΈ
PrioritΓ : π΄ Alta
Effort Stimato: 2-3 settimane
Stato: Proposta
Problemaβ
Attualmente il monitoraggio della piattaforma richiede:
- Controllo manuale dei log su Grafana
- Alert generici che richiedono investigazione manuale
- Intervento umano per risolvere problemi comuni
- Nessuna correlazione automatica tra eventi
Soluzione: AI SRE Agent 24/7β
Un microservice che monitora continuamente la piattaforma e:
- π Rileva anomalie e errori automaticamente
- π§ Analizza root cause con AI
- π§ Esegue auto-remediation per problemi noti
- π Genera report giornalieri
- π‘ Suggerisce miglioramenti proattivi
Architetturaβ
βββββββββββββββββββββββββββββββββββββββββββ
β VISLA GUARDIAN π‘οΈ β
β (AI SRE Agent 24/7) β
βββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β MONITOR β β ANALYZE β β ACT β
β β β β β β
β β’ Logs Loki ββββββββββββββΆβ β’ LLM ββββββββββββββΆβ β’ Auto-fix β
β β’ Metrics β β β’ Patterns β β β’ Scale β
β β’ K8s Eventsβ β β’ Anomalies β β β’ Restart β
β β’ Redis β β β’ Root causeβ β β’ Alert β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β REPORT π β
β β’ Telegram bot β
β β’ Daily summary β
β β’ Improvement ideas β
βββββββββββββββββββββββββββ
FunzionalitΓ β
| Funzione | Esempio | PrioritΓ |
|---|---|---|
| π΄ Auto-Remediation | Pod crashato β restart automatico | Alta |
| π‘ Smart Alerting | "Errore nuovo, sembra correlato a X" | Alta |
| π’ Proactive | "Redis usa 80% RAM, suggerisco cleanup" | Media |
| π Optimization | "Decoder potrebbe scalare in ore di punta" | Bassa |
| π Daily Report | "Ieri: 3 errori risolti, 99.8% uptime" | Media |
Esempi Concretiβ
Auto-Remediationβ
π΅οΈ Guardian: "Rilevato: WebSocket consumer lag > 30 min"
β Azione: Restart pod ws-consumer-xxx
β Risultato: Lag ridotto a 0
β Notifica Telegram: "β
WS consumer lag risolto automaticamente"
Pattern Detectionβ
π΅οΈ Guardian: "Pattern: Device S21L offline ogni giorno alle 14:00"
β Analisi: Correlazione con power-saving mode
β Suggerimento: "Considera di disabilitare NMOD per questi device"
Root Cause Analysisβ
π΅οΈ Guardian: "Anomalia: 50% aumento errori 500 nell'ultima ora"
β Root cause: "Deploy auth-service fallito"
β Azione proposta: kubectl rollout undo deployment/auth
β Attende conferma o agisce automaticamente (configurabile)
Flusso Tecnicoβ
# Ogni 5 minuti il Guardian esegue:
# 1οΈβ£ QUERY LOKI (interno, gratis)
logs = loki.query('{level="error"} | last 5 minutes')
# 2οΈβ£ FILTER LOCALE (no API, gratis)
new_errors = filter_already_seen(logs)
if not new_errors:
return # Niente da fare
# 3οΈβ£ ANALISI AI (unico costo)
analysis = await claude.analyze(
system="Sei un SRE esperto di Visla...",
content=f"Analizza questi errori:\n{sanitize(new_errors)}"
)
# 4οΈβ£ ESEGUI AZIONE (interno, gratis)
if analysis.action == "restart_pod":
kubectl.restart(analysis.pod_name)
telegram.send("β
Riavviato pod X per errore Y")
Sicurezza e Privacyβ
Prima di inviare dati all'LLM:
def sanitize_for_llm(log_line):
log_line = re.sub(r'password=\S+', 'password=***', log_line)
log_line = re.sub(r'token=\S+', 'token=***', log_line)
log_line = re.sub(r'\d{10,}', '[IMEI]', log_line)
return log_line[:500] # Max 500 chars
Costiβ
| Componente | Costo/mese | Note |
|---|---|---|
| GKE Pod | β¬0 | Risorse giΓ disponibili |
| Loki/Grafana | β¬0 | GiΓ attivo |
| Redis | β¬0 | GiΓ attivo |
| Telegram Bot | β¬0 | Free tier |
| LLM API | β¬20-40 | Unico costo reale |
Dettaglio LLM (Claude 3.5 Sonnet)β
| Frequenza | Query/giorno | Costo/mese |
|---|---|---|
| Ogni 5 min | ~288 | ~β¬30 |
| Ogni 15 min | ~96 | ~β¬15 |
| Solo su errori | Variabile | ~β¬10-20 |
Implementazioneβ
Fase 1: MVP (1 settimana)β
- Setup microservice Python/FastAPI
- Query Loki per errori
- Integrazione Claude API
- Notifiche Telegram base
Fase 2: Auto-Remediation (1 settimana)β
- Playbook per problemi comuni
- Kubectl integration
- Confirmation flow (opzionale)
- Audit logging
Fase 3: Intelligence (1 settimana)β
- Pattern detection
- Daily reports
- Suggerimenti proattivi
- Dashboard metriche