Skip to content

Suppress logging for single endpoint for special usage (Kubernetes Liveness Probe) #2731

@sebastianbuechler

Description

@sebastianbuechler

I am using fastapi in a container that is deployed to Kubernetes. Kubernetes offers the feature of liveness and readiness probes which are basically just HTTP get calls watched for status code <400. In fastapi it is easy to just define such an endpoint like this:

@fastapiserver.get("/healthz")
# Liveness probe for kubernetes status service
def kubernetes_liveness_probe():
    return {"status": "healthy"}

However, since the probes call the endpoint quite often (~every 5 seconds) the log gets full of the calls.

How can I suppress logging for a single endpoint without losing the logging for all the others?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions