monitor: False-Positive-Filter für HTTP-Access-Logs

Artikel-Titel mit "fatal" in URLs triggerten Fehlalarme.
GET/POST-Zeilen und erfolgreiche HTTP-Responses werden ignoriert.

Made-with: Cursor
This commit is contained in:
root 2026-03-09 14:15:34 +07:00
parent 8f4b091c64
commit 8d3bb17853

View file

@ -52,11 +52,19 @@ def check_all() -> list[str]:
errors = loki_client.get_errors(hours=0.5, limit=50) errors = loki_client.get_errors(hours=0.5, limit=50)
error_lines = [e for e in errors if "error" not in e] error_lines = [e for e in errors if "error" not in e]
panic_lines = [e for e in error_lines if panic_lines = []
any(w in e.get("line", "").lower() for w in ["panic", "fatal", "oom", "out of memory"]) for e in error_lines:
and "query=" not in e.get("line", "") line = e.get("line", "")
and "caller=metrics" not in e.get("line", "") ll = line.lower()
] if not any(w in ll for w in ["panic", "fatal", "oom", "out of memory"]):
continue
if "query=" in line or "caller=metrics" in line:
continue
if "HTTP/1." in line and ('" 200 ' in line or '" 301 ' in line or '" 302 ' in line or '" 304 ' in line):
continue
if "GET /" in line or "POST /" in line or "HEAD /" in line:
continue
panic_lines.append(e)
if panic_lines: if panic_lines:
hosts = set(e.get("host", "?") for e in panic_lines) hosts = set(e.get("host", "?") for e in panic_lines)
hosts -= IGNORED_HOSTS hosts -= IGNORED_HOSTS