Skip to content

[Feature]: Disable logging /metrics #29023

@robertgshaw2-redhat

Description

@robertgshaw2-redhat

🚀 The feature, motivation and pitch

  • IGW hits /metrics continuously to understand the current load on the system
  • This leads to an overload of logs
  • We can disable this with --disable-uvicorn-access-log, but lose access to all access logs

We should have --disable-uvicorn-metrics-access-log to avoid logging * just * metrics. Per Gemini, we can do this with something like:

# Define the routes for which access logs should be disabled
EXCLUDE_PATHS = ["/health", "/metrics"]

class EndpointFilter(logging.Filter):
    def filter(self, record: logging.LogRecord) -> bool:
        # Check if the log record contains arguments and if the path matches an excluded path
        if record.args and len(record.args) >= 3:
            path = record.args[2]  # The path is typically the third argument in uvicorn access logs
            if path in EXCLUDE_PATHS:
                return False  # Exclude this log record
        return True  # Include all other log records

Create a command line arg like --disable-uvicorn-metrics-access-logwhich selectively disables logging hits to /metrics

Alternatives

No response

Additional context

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions