From bf31e929b521461e7647d870be939297045561f2 Mon Sep 17 00:00:00 2001 From: Antti Kettunen Date: Tue, 21 Apr 2026 18:13:48 +0300 Subject: [PATCH] Filter out curl healthchecks from access logs --- utils/gunicorn_logger.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/gunicorn_logger.py b/utils/gunicorn_logger.py index 9926886d..0dade80b 100644 --- a/utils/gunicorn_logger.py +++ b/utils/gunicorn_logger.py @@ -35,6 +35,10 @@ class FilteredGunicornLogger(GunicornLogger): ".eot", ) + _HEALTHCHECK_USER_AGENTS = ( + "curl/", + ) + def _should_skip_access_log(self, environ) -> bool: path = environ.get("PATH_INFO") or "" if not path: @@ -49,6 +53,11 @@ class FilteredGunicornLogger(GunicornLogger): ): return True + if lower_path == "/": + user_agent = (environ.get("HTTP_USER_AGENT") or "").lower() + if any(token in user_agent for token in self._HEALTHCHECK_USER_AGENTS): + return True + return any(lower_path.endswith(suffix) for suffix in self._STATIC_SUFFIXES) def access(self, resp, req, environ, request_time):