main
Log Analyzer Backend + Frontend
CPU-LLM-gestütztes Dashboard zur Auswertung von Firewall- und Proxy-Logs. Parst Dateien, zeigt übersichtliche Statistiken (Top-Hits, Quellen, Ziele, Ports, URLs, Zeitverlauf) und nutzt ein lokales LLM (via Ollama) für die Analyse.
Features
- Log-Parsing: Unterstützt iptables, pfSense, Cisco ASA, Squid, nginx
- Statistiken: Top Quellen, Ziele, Ports, URLs, Actions, Timeline
- LLM-Analyse: Zusammenfassung und Anomalie-Erkennung via lokalem Ollama-Modell
- REST-API: FastAPI mit automatischer OpenAPI-Doku unter
/docs - Web-Dashboard: Vue 3 + Chart.js SPA, erreichbar auf Port 80
- Docker-Compose: Ein Befehl zum Starten von Backend + Frontend
Architektur
┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐
│ Browser │──────▶│ Frontend:80 │──────▶│ FastAPI Backend:8000 │
└──────────────┘ │ (nginx + │ │ - SQLite (Volumen) │
│ Vue SPA) │ │ - Log-Parser │
└──────────────┘ │ - Ollama-Client │
└───────────────────────┘
│
▼
┌──────────────────────┐
│ Ollama (CPU/Host) │
│ http://host.docker │
│ .internal:11434│
└──────────────────────┘
Voraussetzungen
- Docker + Docker Compose
- Laufende Ollama-Instanz auf dem Host (Port 11434) mit Modell
llava:7b - Ports: 80 (Dashboard), 11434 (Ollama auf Host)
Installation & Start
# Repository klonen
git clone https://gitea.die-heimatlosen.eu/arch_agent/log-analyzer-backend.git
cd log-analyzer-backend
# Starten
docker-compose up -d --build
Das Dashboard ist dann unter http://localhost erreichbar. Die API-Doku unter http://localhost/docs.
Nutzung
Dashboard
- Browser öffnen:
http://localhost - Log-Datei über das Upload-Feld hochladen
- Statistiken und Charts werden automatisch geladen (alle 15 Sek. refreshed)
- LLM-Analyse über den Bereich unten starten
API (cURL)
Log-Datei hochladen
curl -X POST http://localhost/api/upload \
-H "Content-Type: multipart/form-data" \
-F "file=@/var/log/iptables.log"
Statistiken abrufen
curl "http://localhost/api/stats?limit=20"
LLM-Analyse starten
curl -X POST "http://localhost/api/analyze?log_type=firewall&limit=100"
Gesundheitscheck
curl http://localhost/health
API-Endpunkte
| Methode | Endpunkt | Beschreibung |
|---|---|---|
| POST | /api/upload |
Log-Datei hochladen & parsen |
| GET | /api/stats |
Übersicht aller Statistiken |
| GET | /api/stats/sources |
Top Quellen |
| GET | /api/stats/destinations |
Top Ziele |
| GET | /api/stats/ports |
Top Ports |
| POST | /api/analyze |
LLM-Analyse der Logs |
| GET | /health |
Healthcheck |
| GET | /docs |
Swagger UI (FastAPI) |
Umgebungsvariablen
| Variable | Standard | Beschreibung |
|---|---|---|
DATABASE_URL |
sqlite+aiosqlite:///data/logs.db |
SQLite Datenbankpfad |
OLLAMA_URL |
http://host.docker.internal:11434 |
Ollama API URL |
OLLAMA_MODEL |
llava:7b |
LLM Modellname |
Unterstützte Log-Formate
Firewall
- iptables: Kernel-Logzeilen mit
SRC=... DST=... PROTO=... DPT=... - pfSense:
filterlogCSV-ähnliche Zeilen - Cisco ASA:
%ASA-... Built/Teardown/Denied ...
Proxy
- Squid: Native Squid-Logformat (Timestamp, elapsed, client, code, status, size, method, URL)
- nginx: Standard access_log (
$remote_addr - [$time_local] "$request" $status $body_bytes_sent)
Hinweise
- Das Backend erwartet Ollama auf dem Host (nicht im Container). Für Linux ggf.
extra_hosts: ["host.docker.internal:host-gateway"]nutzen. - Große Logdateien werden in Batches von 500 Zeilen verarbeitet.
- Die SQLite-Datenbank wird im Docker-Volumen
logdatapersistiert. - Das Frontend aktualisiert die Statistiken automatisch alle 15 Sekunden.
Lizenz
MIT
Description
Languages
Python
59.9%
JavaScript
14.3%
CSS
12.5%
HTML
12.2%
Dockerfile
1.1%