Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable health check logging in access logging #1781

Closed
thomasjungblut opened this issue May 16, 2018 · 5 comments
Closed

disable health check logging in access logging #1781

thomasjungblut opened this issue May 16, 2018 · 5 comments
Labels
Discussion Feature/Config Feature/Logging help wanted Open for everyone. You do not need permission to work on these. May need familiarity with codebase. Question

Comments

@thomasjungblut
Copy link

we got tons of these in our access log at high frequency (eg. health checks, metric scrapes by prometheus):

"GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.8"

which generally is fine, but very verbose. Can we somehow ignore a path from access logging?

@tilgovi tilgovi added Question Discussion Feature/Logging help wanted Open for everyone. You do not need permission to work on these. May need familiarity with codebase. Feature/Config labels May 16, 2018
@benoitc
Copy link
Owner

benoitc commented Oct 9, 2018

no action since. closing the issue. Also I don't think we should do anything about incoming requests.

@benoitc benoitc closed this as completed Oct 9, 2018
@elijahchancey
Copy link

It'd be great to be able to configure gunicorn to not log healthcheck requests if the result is 200. These definitely crowd my logs too.

@tilgovi
Copy link
Collaborator

tilgovi commented Dec 23, 2019

I don't think it makes sense to add this kind of feature. Gunicorn uses Python logging. You can definitely implement a log filter of some kind at the Python level or lower. You could filter the output steam, or filter the log lines as they are forwarded to an aggregator system. I just can't see a way it feels right to implement features in the core of Gunicorn for this.

@EvertonSA
Copy link

FYI:

for fastapi with uvicorn it works like:

class HealthCheckFilter(logging.Filter):
    def filter(self, record: logging.LogRecord) -> bool:
        return record.getMessage().find("/health") == -1


# Remove /credentials/health from application server logs
logging.getLogger("uvicorn.access").addFilter(HealthCheckFilter())

logger = logging.getLogger(__name__)

@nisarg-ss
Copy link

FYI:

for fastapi with uvicorn it works like:

class HealthCheckFilter(logging.Filter):
    def filter(self, record: logging.LogRecord) -> bool:
        return record.getMessage().find("/health") == -1


# Remove /credentials/health from application server logs
logging.getLogger("uvicorn.access").addFilter(HealthCheckFilter())

logger = logging.getLogger(__name__)

Thanks @EvertonSA .......For Saving a ton of time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Feature/Config Feature/Logging help wanted Open for everyone. You do not need permission to work on these. May need familiarity with codebase. Question
Projects
None yet
Development

No branches or pull requests

6 participants