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:
parent
8f4b091c64
commit
8d3bb17853
1 changed files with 13 additions and 5 deletions
|
|
@ -52,11 +52,19 @@ def check_all() -> list[str]:
|
|||
|
||||
errors = loki_client.get_errors(hours=0.5, limit=50)
|
||||
error_lines = [e for e in errors if "error" not in e]
|
||||
panic_lines = [e for e in error_lines if
|
||||
any(w in e.get("line", "").lower() for w in ["panic", "fatal", "oom", "out of memory"])
|
||||
and "query=" not in e.get("line", "")
|
||||
and "caller=metrics" not in e.get("line", "")
|
||||
]
|
||||
panic_lines = []
|
||||
for e in error_lines:
|
||||
line = 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:
|
||||
hosts = set(e.get("host", "?") for e in panic_lines)
|
||||
hosts -= IGNORED_HOSTS
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue