Add GoAccess log analytics at /logs (admin-only)

- GoAccess installed and running as systemd service (goaccess.service)
- Real-time HTML report at /var/www/html/report.html
- /logs route serves GoAccess dashboard, protected by @admin_required
- "Logs" link added to admin panel nav (orange)
- Auto-starts on boot, reads nginx access.log

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
root 2026-03-25 03:46:16 -05:00
parent c493b10d2d
commit 5df00a4018

View File

@ -318,6 +318,16 @@ def demo_set_allowlist():
return jsonify({"ips": sorted(ALLOWLIST_IPS)})
@app.route("/logs")
@admin_required
def logs_page():
try:
with open("/var/www/html/report.html") as f:
return f.read()
except Exception:
return "GoAccess report not found. Run: goaccess /var/log/nginx/access.log -o /var/www/html/report.html --log-format=COMBINED", 404
CONFIG_PATH = "/root/llm_team_config.json"
DEFAULT_CONFIG = {
"providers": {
@ -1275,7 +1285,7 @@ ADMIN_HTML = r"""
<div class="container">
<header>
<h1><span>LLM</span> Team Admin</h1>
<nav style="margin-left:auto;display:flex;gap:8px;align-items:center"><a href="/">Team UI</a><a href="/lab" style="color:var(--green)">Lab</a><span style="opacity:0.3">|</span><a href="/logout" style="opacity:0.5;font-size:11px">Logout</a></nav>
<nav style="margin-left:auto;display:flex;gap:8px;align-items:center"><a href="/">Team UI</a><a href="/lab" style="color:var(--green)">Lab</a><a href="/logs" style="color:var(--orange)">Logs</a><span style="opacity:0.3">|</span><a href="/logout" style="opacity:0.5;font-size:11px">Logout</a></nav>
</header>
<div class="tabs">
<div class="tab active" onclick="switchTab('providers')">Providers</div>